Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-02-20 09:42:18
Exec Total Coverage
Lines: 1725 3952 43.6%
Functions: 127 339 37.5%
Branches: 943 2722 34.6%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 bool epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101 bool is_sys_pal = false;
102 static bool load_control_called_this_frame;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 78255 bool flash_reduction_enabled(bool check_qr)
171 {
172
4/4
✓ Branch 0 taken 76034 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 75578 times.
✓ Branch 3 taken 77799 times.
78255 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
173 }
174
175 // Dialogue largening
176 void large_dialog(DIALOG *d)
177 {
178 large_dialog(d, 1.5);
179 }
180
181 void large_dialog(DIALOG *d, float RESIZE_AMT)
182 {
183 if(!d[0].d1)
184 {
185 d[0].d1 = 1;
186 int32_t oldwidth = d[0].w;
187 int32_t oldheight = d[0].h;
188 int32_t oldx = d[0].x;
189 int32_t oldy = d[0].y;
190 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
191 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
192 d[0].w = int32_t(d[0].w*RESIZE_AMT);
193 d[0].h = int32_t(d[0].h*RESIZE_AMT);
194
195 for(int32_t i=1; d[i].proc !=NULL; i++)
196 {
197 // Place elements horizontally
198 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
199 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
200
201 if(d[i].proc != d_stringloader)
202 {
203 if(d[i].proc==d_bitmap_proc)
204 {
205 d[i].w *= 2;
206 }
207 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
208 }
209
210 // Place elements vertically
211 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
212 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
213
214 // Vertically resize elements
215 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
216 {
217 d[i].h = int32_t((double)d[i].h*1.5);
218 }
219 else if(d[i].proc == jwin_droplist_proc)
220 {
221 d[i].y += int32_t((double)d[i].h*0.25);
222 d[i].h = int32_t((double)d[i].h*1.25);
223 }
224 else if(d[i].proc==d_bitmap_proc)
225 {
226 d[i].h *= 2;
227 }
228 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
229
230 // Fix frames
231 if(d[i].proc == jwin_frame_proc)
232 {
233 d[i].x++;
234 d[i].y++;
235 d[i].w-=4;
236 d[i].h-=4;
237 }
238 }
239 }
240
241 for(int32_t i=1; d[i].proc!=NULL; i++)
242 {
243 if(d[i].proc==jwin_slider_proc)
244 continue;
245
246 // Bigger font
247 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
248
249 if(!d[i].dp2 && bigfontproc)
250 {
251 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
252 d[i].dp2 = lfont_l;
253 }
254 else if(!bigfontproc)
255 {
256 // ((ListData *)d[i].dp)->font = &sfont3;
257 ((ListData *)d[i].dp)->font = &lfont_l;
258 }
259
260 // Make checkboxes work
261 if(d[i].proc == jwin_check_proc)
262 d[i].proc = jwin_checkfont_proc;
263 else if(d[i].proc == jwin_radio_proc)
264 d[i].proc = jwin_radiofont_proc;
265 }
266
267 jwin_center_dialog(d);
268 }
269
270
271 /**********************************/
272 /******** System functions ********/
273 /**********************************/
274
275 static char cfg_sect[] = "zeldadx"; //We need to rename this.
276 static char ctrl_sect[] = "Controls";
277 static char sfx_sect[] = "Volume";
278
279 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
280 {
281 return D_O_K;
282 }
283
284 28 void load_game_configs()
285 {
286 28 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
287 28 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
288 28 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
289 28 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
290 28 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
291 28 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
292 28 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
293 28 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
294 28 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
295 28 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
296 28 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
297 28 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
298 28 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
299 28 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
300 28 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
301
302 //cheat modifier keya
303 28 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
304 28 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
305 28 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
306 28 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
307
308
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
309 joystick_index = 0;
310
311 28 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
312 28 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
313 28 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
314 28 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
315 28 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
316 28 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
317 28 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
318 28 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
319 28 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
320 28 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
321
322 28 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
323 28 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
324 28 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
325 28 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
326
327 28 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
328 28 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
329 28 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
330 28 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
331 28 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
332 28 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
333 28 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
334 28 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
335 28 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
336 28 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
337 28 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
338
339 28 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
340 28 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
341 28 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
342 28 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
343
344 28 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
345
346 28 digi_volume = zc_get_config(sfx_sect,"digi",248);
347 28 midi_volume = zc_get_config(sfx_sect,"midi",255);
348 28 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
349 28 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
350 28 pan_style = zc_get_config(sfx_sect,"pan",1);
351 // 1 <= zcmusic_bufsz <= 128
352 28 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
353 28 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
354 28 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
355 28 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
356 28 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
357 28 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
358 28 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
359 #ifdef __EMSCRIPTEN__
360 if (em_is_mobile()) NameEntryMode = 2;
361 #endif
362 28 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
363 28 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
364 28 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
365 28 title_version = zc_get_config(cfg_sect,"title",2);
366 28 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
367 28 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
368
369 //default - scale x2, 640 x 480
370 28 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
371 28 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
372 28 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
373 28 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
374 28 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
375
376 28 loadlast = zc_get_config(cfg_sect,"load_last",0);
377
378 28 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
379
380 28 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
381
382 28 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
383
384 #ifdef _WIN32
385 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
386 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
387 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
388 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
389
390 // This one's for Aero
391 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
392
393 // And this one fixes patches unloading on some MIDI setups
394 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
395 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
396 #else //UNIX
397 28 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
398 28 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
399 28 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
400 #endif
401 28 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
402
403 28 char const* default_path = "";
404 28 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
405
406
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(strlen(qstdir)==0)
407 {
408 28 getcwd(qstdir,2048);
409 28 fix_filename_case(qstdir);
410 28 fix_filename_slashes(qstdir);
411 28 put_backslash(qstdir);
412 28 }
413 else
414 {
415 chop_path(qstdir);
416 }
417
418 28 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
419 28 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
420 28 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
421 28 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
422 28 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
423 28 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
424 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
425 28 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
426 28 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
427 28 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
428 28 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
429 28 }
430
431 void save_control_configs(bool kb)
432 {
433 if(kb)
434 {
435 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
436 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
437 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
438 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
439
440 if (!replay_is_replaying())
441 {
442 zc_set_config(ctrl_sect,"key_a",Akey);
443 zc_set_config(ctrl_sect,"key_b",Bkey);
444 zc_set_config(ctrl_sect,"key_s",Skey);
445 zc_set_config(ctrl_sect,"key_l",Lkey);
446 zc_set_config(ctrl_sect,"key_r",Rkey);
447 zc_set_config(ctrl_sect,"key_p",Pkey);
448 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
449 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
450 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
451 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
452 zc_set_config(ctrl_sect,"key_up", DUkey);
453 zc_set_config(ctrl_sect,"key_down", DDkey);
454 zc_set_config(ctrl_sect,"key_left", DLkey);
455 zc_set_config(ctrl_sect,"key_right",DRkey);
456 }
457 }
458 else
459 {
460 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
461 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
462 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
463 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
464 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
465 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
466 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
467 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
468 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
469 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
470 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
471 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
472 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
473 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
474
475 zc_set_config(ctrl_sect,"btn_a",Abtn);
476 zc_set_config(ctrl_sect,"btn_b",Bbtn);
477 zc_set_config(ctrl_sect,"btn_s",Sbtn);
478 zc_set_config(ctrl_sect,"btn_m",Mbtn);
479 zc_set_config(ctrl_sect,"btn_l",Lbtn);
480 zc_set_config(ctrl_sect,"btn_r",Rbtn);
481 zc_set_config(ctrl_sect,"btn_p",Pbtn);
482 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
483 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
484 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
485 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
486
487 zc_set_config(ctrl_sect,"btn_up",DUbtn);
488 zc_set_config(ctrl_sect,"btn_down",DDbtn);
489 zc_set_config(ctrl_sect,"btn_left",DLbtn);
490 zc_set_config(ctrl_sect,"btn_right",DRbtn);
491 }
492 }
493
494 void save_game_configs()
495 {
496 packfile_password("");
497
498 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
499
500 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
501 {
502 int o_window_x, o_window_y;
503 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
504 zc_set_config(cfg_sect,"window_x",o_window_x);
505 zc_set_config(cfg_sect,"window_y",o_window_y);
506 }
507
508 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
509 {
510 double monitor_scale = zc_get_monitor_scale();
511 window_width = al_get_display_width(all_get_display()) / monitor_scale;
512 window_height = al_get_display_height(all_get_display()) / monitor_scale;
513 zc_set_config(cfg_sect,"window_width",window_width);
514 zc_set_config(cfg_sect,"window_height",window_height);
515 }
516
517 zc_set_config(cfg_sect,"load_last",loadlast);
518 chop_path(qstdir);
519 zc_set_config(cfg_sect,qst_dir_name,qstdir);
520 zc_set_config("SAVEFILE","save_filename",save_file_name);
521 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
522
523 flush_config_file();
524 #ifdef __EMSCRIPTEN__
525 em_sync_fs();
526 #endif
527 }
528
529 //----------------------------------------------------------------
530
531 // Timers
532
533 19999 void fps_callback()
534 {
535 19999 lastfps=framecnt;
536 19999 dword tempsecs = fps_secs;
537 19999 ++tempsecs;
538 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
539 19999 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
540 19999 ++fps_secs;
541 19999 framecnt=0;
542 19999 }
543
544 END_OF_FUNCTION(fps_callback)
545
546 28 int32_t Z_init_timers()
547 {
548 static bool didit = false;
549 const static char *err_str = "Couldn't allocate timer";
550 28 err_str = err_str; //Unused variable warning
551
552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(didit)
553 return 1;
554
555 28 didit = true;
556
557 LOCK_VARIABLE(lastfps);
558 LOCK_VARIABLE(framecnt);
559 LOCK_FUNCTION(fps_callback);
560
561
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
562 return 0;
563
564 28 return 1;
565 28 }
566
567 void Z_remove_timers()
568 {
569 remove_int(fps_callback);
570 }
571
572 //----------------------------------------------------------------
573
574 void go()
575 {
576 scare_mouse();
577 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
578 unscare_mouse();
579 }
580
581 void comeback()
582 {
583 scare_mouse();
584 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
585 unscare_mouse();
586 }
587
588 void dump_pal(BITMAP *dest)
589 {
590 for(int32_t i=0; i<256; i++)
591 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
592 }
593
594 //----------------------------------------------------------------
595
596 //Handles converting the mouse sprite from the .dat file
597 28 void load_mouse()
598 {
599 28 system_pal();
600 28 scare_mouse();
601 28 set_mouse_sprite(NULL);
602
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
603
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(int32_t j = 0; j < 4; ++j)
604 {
605 112 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
606 112 BITMAP* subbmp = create_bitmap_ex(8,16,16);
607
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(zcmouse[j])
608 destroy_bitmap(zcmouse[j]);
609 112 zcmouse[j] = create_bitmap_ex(8,sz,sz);
610 112 clear_bitmap(zcmouse[j]);
611 112 clear_bitmap(tmpbmp);
612 112 clear_bitmap(subbmp);
613 112 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
614
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 112 times.
1904 for(int32_t x = 0; x < 16; ++x)
615 {
616
2/2
✓ Branch 0 taken 28672 times.
✓ Branch 1 taken 1792 times.
30464 for(int32_t y = 0; y < 16; ++y)
617 {
618 28672 int32_t color = getpixel(tmpbmp, x, y);
619
5/5
✓ Branch 0 taken 26376 times.
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 616 times.
✓ Branch 3 taken 644 times.
✓ Branch 4 taken 504 times.
28672 switch(color)
620 {
621 case dvc(1):
622 532 color = jwin_pal[jcCURSORMISC];
623 532 break;
624 case dvc(2):
625 616 color = jwin_pal[jcCURSOROUTLINE];
626 616 break;
627 case dvc(3):
628 644 color = jwin_pal[jcCURSORLIGHT];
629 644 break;
630 case dvc(5):
631 504 color = jwin_pal[jcCURSORDARK];
632 504 break;
633 }
634 28672 putpixel(subbmp, x, y, color);
635 28672 }
636 1792 }
637
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(sz!=16)
638 112 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
639 else
640 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
641 112 destroy_bitmap(tmpbmp);
642 112 destroy_bitmap(subbmp);
643 112 }
644 28 set_mouse_sprite(zcmouse[0]);
645
646 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
647 28 set_palette(*hw_palette);
648 28 show_mouse(screen);
649 28 show_mouse(NULL);
650
651 28 unscare_mouse();
652 28 game_pal();
653 28 }
654
655 // sets the video mode and initializes the palette and mouse sprite
656 28 bool game_vid_mode(int32_t mode,int32_t wait)
657 {
658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
659 {
660 return false;
661 }
662
663 28 scrx = (resx-320)>>1;
664 28 scry = (resy-240)>>1;
665
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(int32_t q = 0; q < 4; ++q)
666 112 zcmouse[q] = NULL;
667 28 load_mouse();
668 28 set_mouse_sprite(zcmouse[0]);
669
670
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 28 times.
476 for(int32_t i=240; i<256; i++)
671 448 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
672
673 28 set_palette(RAMpal);
674 28 clear_to_color(screen,BLACK);
675
676 28 rest(wait);
677 28 return true;
678 28 }
679
680 4 void null_quest()
681 {
682 char qstdat_string[2048];
683 4 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
684 4 strcat(qstdat_string,"#NESQST_NEW_QST");
685
686 #ifdef __EMSCRIPTEN__
687 // The quest template data file is not included because it's really big and isn't really needed
688 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
689 // which is much smaller.
690 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
691 #endif
692
693 4 byte skip_flags[4] = { 0 };
694
695 4 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
696 4 }
697
698 4 void init_NES_mode()
699 {
700 /*
701 // qst.dat may not load correctly without this...
702 QHeader.templatepath[0]='\0';
703
704 if(!init_colordata(true, &QHeader, &QMisc))
705 {
706 return;
707 }
708
709 loadfullpal();
710 init_tiles(false, &QHeader);
711 */
712 4 null_quest();
713 4 }
714
715 //----------------------------------------------------------------
716
717 qword trianglelines[16]=
718 {
719 0x0000000000000000ULL,
720 0xFD00000000000000ULL,
721 0xFDFD000000000000ULL,
722 0xFDFDFD0000000000ULL,
723 0xFDFDFDFD00000000ULL,
724 0xFDFDFDFDFD000000ULL,
725 0xFDFDFDFDFDFD0000ULL,
726 0xFDFDFDFDFDFDFD00ULL,
727 0xFDFDFDFDFDFDFDFDULL,
728 0x00FDFDFDFDFDFDFDULL,
729 0x0000FDFDFDFDFDFDULL,
730 0x000000FDFDFDFDFDULL,
731 0x00000000FDFDFDFDULL,
732 0x0000000000FDFDFDULL,
733 0x000000000000FDFDULL,
734 0x00000000000000FDULL,
735 };
736
737 word screen_triangles[28][32];
738 /*
739 qword triangles[4][16]= //[direction][value]
740 {
741 {
742 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
743 },
744 {
745 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
746 },
747 {
748 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
749 },
750 {
751 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
752 }
753 };
754 */
755
756
757 /*
758 byte triangles[4][16][8]= //[direction][value][line]
759 {
760 {
761 {
762 0, 0, 0, 0, 0, 0, 0, 0
763 },
764 {
765 1, 0, 0, 0, 0, 0, 0, 0
766 },
767 {
768 2, 1, 0, 0, 0, 0, 0, 0
769 },
770 {
771 3, 2, 1, 0, 0, 0, 0, 0
772 },
773 {
774 4, 3, 2, 1, 0, 0, 0, 0
775 },
776 {
777 5, 4, 3, 2, 1, 0, 0, 0
778 },
779 {
780 6, 5, 4, 3, 2, 1, 0, 0
781 },
782 {
783 7, 6, 5, 4, 3, 2, 1, 0
784 },
785 {
786 8, 7, 6, 5, 4, 3, 2, 1
787 },
788 {
789 8, 8, 7, 6, 5, 4, 3, 2
790 },
791 {
792 8, 8, 8, 7, 6, 5, 4, 3
793 },
794 {
795 8, 8, 8, 8, 7, 6, 5, 4
796 },
797 {
798 8, 8, 8, 8, 8, 7, 6, 5
799 },
800 {
801 8, 8, 8, 8, 8, 8, 7, 6
802 },
803 {
804 8, 8, 8, 8, 8, 8, 8, 7
805 },
806 {
807 8, 8, 8, 8, 8, 8, 8, 8
808 }
809 },
810 {
811 {
812 0, 0, 0, 0, 0, 0, 0, 0
813 },
814 {
815 15, 0, 0, 0, 0, 0, 0, 0
816 },
817 {
818 14, 15, 0, 0, 0, 0, 0, 0
819 },
820 {
821 13, 14, 15, 0, 0, 0, 0, 0
822 },
823 {
824 12, 13, 14, 15, 0, 0, 0, 0
825 },
826 {
827 11, 12, 13, 14, 15, 0, 0, 0
828 },
829 {
830 10, 11, 12, 13, 14, 15, 0, 0
831 },
832 {
833 9, 10, 11, 12, 13, 14, 15, 0
834 },
835 {
836 8, 9, 10, 11, 12, 13, 14, 15
837 },
838 {
839 8, 8, 9, 10, 11, 12, 13, 14
840 },
841 {
842 8, 8, 8, 9, 10, 11, 12, 13
843 },
844 {
845 8, 8, 8, 8, 9, 10, 11, 12
846 },
847 {
848 8, 8, 8, 8, 8, 9, 10, 11
849 },
850 {
851 8, 8, 8, 8, 8, 8, 9, 10
852 },
853 {
854 8, 8, 8, 8, 8, 8, 8, 9
855 },
856 {
857 8, 8, 8, 8, 8, 8, 8, 8
858 }
859 },
860 {
861 {
862 0, 0, 0, 0, 0, 0, 0, 0
863 },
864 {
865 0, 0, 0, 0, 0, 0, 0, 1
866 },
867 {
868 0, 0, 0, 0, 0, 0, 1, 2
869 },
870 {
871 0, 0, 0, 0, 0, 1, 2, 3
872 },
873 {
874 0, 0, 0, 0, 1, 2, 3, 4
875 },
876 {
877 0, 0, 0, 1, 2, 3, 4, 5
878 },
879 {
880 0, 0, 1, 2, 3, 4, 5, 6
881 },
882 {
883 0, 1, 2, 3, 4, 5, 6, 7
884 },
885 {
886 1, 2, 3, 4, 5, 6, 7, 8
887 },
888 {
889 2, 3, 4, 5, 6, 7, 8, 8
890 },
891 {
892 3, 4, 5, 6, 7, 8, 8, 8
893 },
894 {
895 4, 5, 6, 7, 8, 8, 8, 8
896 },
897 {
898 5, 6, 7, 8, 8, 8, 8, 8
899 },
900 {
901 6, 7, 8, 8, 8, 8, 8, 8
902 },
903 {
904 7, 8, 8, 8, 8, 8, 8, 8
905 },
906 {
907 8, 8, 8, 8, 8, 8, 8, 8
908 }
909 },
910 {
911 {
912 0, 0, 0, 0, 0, 0, 0, 0
913 },
914 {
915 0, 0, 0, 0, 0, 0, 0, 15
916 },
917 {
918 0, 0, 0, 0, 0, 0, 15, 14
919 },
920 {
921 0, 0, 0, 0, 0, 15, 14, 13
922 },
923 {
924 0, 0, 0, 0, 15, 14, 13, 12
925 },
926 {
927 0, 0, 0, 15, 14, 13, 12, 11
928 },
929 {
930 0, 0, 15, 14, 13, 12, 11, 10
931 },
932 {
933 0, 15, 14, 13, 12, 11, 10, 9
934 },
935 {
936 15, 14, 13, 12, 11, 10, 9, 8
937 },
938 {
939 14, 13, 12, 11, 10, 9, 8, 8
940 },
941 {
942 13, 12, 11, 10, 9, 8, 8, 8
943 },
944 {
945 12, 11, 10, 9, 8, 8, 8, 8
946 },
947 {
948 11, 10, 9, 8, 8, 8, 8, 8
949 },
950 {
951 10, 9, 8, 8, 8, 8, 8, 8
952 },
953 {
954 9, 8, 8, 8, 8, 8, 8, 8
955 },
956 {
957 8, 8, 8, 8, 8, 8, 8, 8
958 }
959 }
960 };
961 */
962
963
964
965 /*
966 for (int32_t blockrow=0; blockrow<30; ++i)
967 {
968 for (int32_t linerow=0; linerow<8; ++i)
969 {
970 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
971 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
972 {
973 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
974 ++triangleline;
975 }
976 }
977 }
978 */
979
980 // the ULL suffixes are to prevent this warning:
981 // warning: integer constant is too large for "int32_t" type
982
983 qword triangles[4][16][8]= //[direction][value][line]
984 {
985 {
986 {
987 0x0000000000000000ULL,
988 0x0000000000000000ULL,
989 0x0000000000000000ULL,
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL
995 },
996 {
997 0xFD00000000000000ULL,
998 0x0000000000000000ULL,
999 0x0000000000000000ULL,
1000 0x0000000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL
1005 },
1006 {
1007 0xFDFD000000000000ULL,
1008 0xFD00000000000000ULL,
1009 0x0000000000000000ULL,
1010 0x0000000000000000ULL,
1011 0x0000000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL
1015 },
1016 {
1017 0xFDFDFD0000000000ULL,
1018 0xFDFD000000000000ULL,
1019 0xFD00000000000000ULL,
1020 0x0000000000000000ULL,
1021 0x0000000000000000ULL,
1022 0x0000000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL
1025 },
1026 {
1027 0xFDFDFDFD00000000ULL,
1028 0xFDFDFD0000000000ULL,
1029 0xFDFD000000000000ULL,
1030 0xFD00000000000000ULL,
1031 0x0000000000000000ULL,
1032 0x0000000000000000ULL,
1033 0x0000000000000000ULL,
1034 0x0000000000000000ULL
1035 },
1036 {
1037 0xFDFDFDFDFD000000ULL,
1038 0xFDFDFDFD00000000ULL,
1039 0xFDFDFD0000000000ULL,
1040 0xFDFD000000000000ULL,
1041 0xFD00000000000000ULL,
1042 0x0000000000000000ULL,
1043 0x0000000000000000ULL,
1044 0x0000000000000000ULL
1045 },
1046 {
1047 0xFDFDFDFDFDFD0000ULL,
1048 0xFDFDFDFDFD000000ULL,
1049 0xFDFDFDFD00000000ULL,
1050 0xFDFDFD0000000000ULL,
1051 0xFDFD000000000000ULL,
1052 0xFD00000000000000ULL,
1053 0x0000000000000000ULL,
1054 0x0000000000000000ULL
1055 },
1056 {
1057 0xFDFDFDFDFDFDFD00ULL,
1058 0xFDFDFDFDFDFD0000ULL,
1059 0xFDFDFDFDFD000000ULL,
1060 0xFDFDFDFD00000000ULL,
1061 0xFDFDFD0000000000ULL,
1062 0xFDFD000000000000ULL,
1063 0xFD00000000000000ULL,
1064 0x0000000000000000ULL
1065 },
1066 {
1067 0xFDFDFDFDFDFDFDFDULL,
1068 0xFDFDFDFDFDFDFD00ULL,
1069 0xFDFDFDFDFDFD0000ULL,
1070 0xFDFDFDFDFD000000ULL,
1071 0xFDFDFDFD00000000ULL,
1072 0xFDFDFD0000000000ULL,
1073 0xFDFD000000000000ULL,
1074 0xFD00000000000000ULL
1075 },
1076 {
1077 0xFDFDFDFDFDFDFDFDULL,
1078 0xFDFDFDFDFDFDFDFDULL,
1079 0xFDFDFDFDFDFDFD00ULL,
1080 0xFDFDFDFDFDFD0000ULL,
1081 0xFDFDFDFDFD000000ULL,
1082 0xFDFDFDFD00000000ULL,
1083 0xFDFDFD0000000000ULL,
1084 0xFDFD000000000000ULL
1085 },
1086 {
1087 0xFDFDFDFDFDFDFDFDULL,
1088 0xFDFDFDFDFDFDFDFDULL,
1089 0xFDFDFDFDFDFDFDFDULL,
1090 0xFDFDFDFDFDFDFD00ULL,
1091 0xFDFDFDFDFDFD0000ULL,
1092 0xFDFDFDFDFD000000ULL,
1093 0xFDFDFDFD00000000ULL,
1094 0xFDFDFD0000000000ULL
1095 },
1096 {
1097 0xFDFDFDFDFDFDFDFDULL,
1098 0xFDFDFDFDFDFDFDFDULL,
1099 0xFDFDFDFDFDFDFDFDULL,
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFD00ULL,
1102 0xFDFDFDFDFDFD0000ULL,
1103 0xFDFDFDFDFD000000ULL,
1104 0xFDFDFDFD00000000ULL
1105 },
1106 {
1107 0xFDFDFDFDFDFDFDFDULL,
1108 0xFDFDFDFDFDFDFDFDULL,
1109 0xFDFDFDFDFDFDFDFDULL,
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFD00ULL,
1113 0xFDFDFDFDFDFD0000ULL,
1114 0xFDFDFDFDFD000000ULL
1115 },
1116 {
1117 0xFDFDFDFDFDFDFDFDULL,
1118 0xFDFDFDFDFDFDFDFDULL,
1119 0xFDFDFDFDFDFDFDFDULL,
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFD00ULL,
1124 0xFDFDFDFDFDFD0000ULL
1125 },
1126 {
1127 0xFDFDFDFDFDFDFDFDULL,
1128 0xFDFDFDFDFDFDFDFDULL,
1129 0xFDFDFDFDFDFDFDFDULL,
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFD00ULL
1135 },
1136 {
1137 0xFDFDFDFDFDFDFDFDULL,
1138 0xFDFDFDFDFDFDFDFDULL,
1139 0xFDFDFDFDFDFDFDFDULL,
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL
1145 }
1146 },
1147 {
1148 {
1149 0x0000000000000000ULL,
1150 0x0000000000000000ULL,
1151 0x0000000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL
1157 },
1158 {
1159 0x00000000000000FDULL,
1160 0x0000000000000000ULL,
1161 0x0000000000000000ULL,
1162 0x0000000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL
1167 },
1168 {
1169 0x000000000000FDFDULL,
1170 0x00000000000000FDULL,
1171 0x0000000000000000ULL,
1172 0x0000000000000000ULL,
1173 0x0000000000000000ULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL
1177 },
1178 {
1179 0x0000000000FDFDFDULL,
1180 0x000000000000FDFDULL,
1181 0x00000000000000FDULL,
1182 0x0000000000000000ULL,
1183 0x0000000000000000ULL,
1184 0x0000000000000000ULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL
1187 },
1188 {
1189 0x00000000FDFDFDFDULL,
1190 0x0000000000FDFDFDULL,
1191 0x000000000000FDFDULL,
1192 0x00000000000000FDULL,
1193 0x0000000000000000ULL,
1194 0x0000000000000000ULL,
1195 0x0000000000000000ULL,
1196 0x0000000000000000ULL
1197 },
1198 {
1199 0x000000FDFDFDFDFDULL,
1200 0x00000000FDFDFDFDULL,
1201 0x0000000000FDFDFDULL,
1202 0x000000000000FDFDULL,
1203 0x00000000000000FDULL,
1204 0x0000000000000000ULL,
1205 0x0000000000000000ULL,
1206 0x0000000000000000ULL
1207 },
1208 {
1209 0x0000FDFDFDFDFDFDULL,
1210 0x000000FDFDFDFDFDULL,
1211 0x00000000FDFDFDFDULL,
1212 0x0000000000FDFDFDULL,
1213 0x000000000000FDFDULL,
1214 0x00000000000000FDULL,
1215 0x0000000000000000ULL,
1216 0x0000000000000000ULL
1217 },
1218 {
1219 0x00FDFDFDFDFDFDFDULL,
1220 0x0000FDFDFDFDFDFDULL,
1221 0x000000FDFDFDFDFDULL,
1222 0x00000000FDFDFDFDULL,
1223 0x0000000000FDFDFDULL,
1224 0x000000000000FDFDULL,
1225 0x00000000000000FDULL,
1226 0x0000000000000000ULL
1227 },
1228 {
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0x00FDFDFDFDFDFDFDULL,
1231 0x0000FDFDFDFDFDFDULL,
1232 0x000000FDFDFDFDFDULL,
1233 0x00000000FDFDFDFDULL,
1234 0x0000000000FDFDFDULL,
1235 0x000000000000FDFDULL,
1236 0x00000000000000FDULL
1237 },
1238 {
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0x00FDFDFDFDFDFDFDULL,
1242 0x0000FDFDFDFDFDFDULL,
1243 0x000000FDFDFDFDFDULL,
1244 0x00000000FDFDFDFDULL,
1245 0x0000000000FDFDFDULL,
1246 0x000000000000FDFDULL
1247 },
1248 {
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0x00FDFDFDFDFDFDFDULL,
1253 0x0000FDFDFDFDFDFDULL,
1254 0x000000FDFDFDFDFDULL,
1255 0x00000000FDFDFDFDULL,
1256 0x0000000000FDFDFDULL
1257 },
1258 {
1259 0xFDFDFDFDFDFDFDFDULL,
1260 0xFDFDFDFDFDFDFDFDULL,
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0x00FDFDFDFDFDFDFDULL,
1264 0x0000FDFDFDFDFDFDULL,
1265 0x000000FDFDFDFDFDULL,
1266 0x00000000FDFDFDFDULL
1267 },
1268 {
1269 0xFDFDFDFDFDFDFDFDULL,
1270 0xFDFDFDFDFDFDFDFDULL,
1271 0xFDFDFDFDFDFDFDFDULL,
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0x00FDFDFDFDFDFDFDULL,
1275 0x0000FDFDFDFDFDFDULL,
1276 0x000000FDFDFDFDFDULL
1277 },
1278 {
1279 0xFDFDFDFDFDFDFDFDULL,
1280 0xFDFDFDFDFDFDFDFDULL,
1281 0xFDFDFDFDFDFDFDFDULL,
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0x00FDFDFDFDFDFDFDULL,
1286 0x0000FDFDFDFDFDFDULL
1287 },
1288 {
1289 0xFDFDFDFDFDFDFDFDULL,
1290 0xFDFDFDFDFDFDFDFDULL,
1291 0xFDFDFDFDFDFDFDFDULL,
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0x00FDFDFDFDFDFDFDULL
1297 },
1298 {
1299 0xFDFDFDFDFDFDFDFDULL,
1300 0xFDFDFDFDFDFDFDFDULL,
1301 0xFDFDFDFDFDFDFDFDULL,
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL
1307 }
1308 },
1309 {
1310 {
1311 0x0000000000000000ULL,
1312 0x0000000000000000ULL,
1313 0x0000000000000000ULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL
1319 },
1320 {
1321 0x0000000000000000ULL,
1322 0x0000000000000000ULL,
1323 0x0000000000000000ULL,
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0xFD00000000000000ULL
1329 },
1330 {
1331 0x0000000000000000ULL,
1332 0x0000000000000000ULL,
1333 0x0000000000000000ULL,
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0xFD00000000000000ULL,
1338 0xFDFD000000000000ULL
1339 },
1340 {
1341 0x0000000000000000ULL,
1342 0x0000000000000000ULL,
1343 0x0000000000000000ULL,
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0xFD00000000000000ULL,
1347 0xFDFD000000000000ULL,
1348 0xFDFDFD0000000000ULL
1349 },
1350 {
1351 0x0000000000000000ULL,
1352 0x0000000000000000ULL,
1353 0x0000000000000000ULL,
1354 0x0000000000000000ULL,
1355 0xFD00000000000000ULL,
1356 0xFDFD000000000000ULL,
1357 0xFDFDFD0000000000ULL,
1358 0xFDFDFDFD00000000ULL
1359 },
1360 {
1361 0x0000000000000000ULL,
1362 0x0000000000000000ULL,
1363 0x0000000000000000ULL,
1364 0xFD00000000000000ULL,
1365 0xFDFD000000000000ULL,
1366 0xFDFDFD0000000000ULL,
1367 0xFDFDFDFD00000000ULL,
1368 0xFDFDFDFDFD000000ULL
1369 },
1370 {
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0xFD00000000000000ULL,
1374 0xFDFD000000000000ULL,
1375 0xFDFDFD0000000000ULL,
1376 0xFDFDFDFD00000000ULL,
1377 0xFDFDFDFDFD000000ULL,
1378 0xFDFDFDFDFDFD0000ULL
1379 },
1380 {
1381 0x0000000000000000ULL,
1382 0xFD00000000000000ULL,
1383 0xFDFD000000000000ULL,
1384 0xFDFDFD0000000000ULL,
1385 0xFDFDFDFD00000000ULL,
1386 0xFDFDFDFDFD000000ULL,
1387 0xFDFDFDFDFDFD0000ULL,
1388 0xFDFDFDFDFDFDFD00ULL
1389 },
1390 {
1391 0xFD00000000000000ULL,
1392 0xFDFD000000000000ULL,
1393 0xFDFDFD0000000000ULL,
1394 0xFDFDFDFD00000000ULL,
1395 0xFDFDFDFDFD000000ULL,
1396 0xFDFDFDFDFDFD0000ULL,
1397 0xFDFDFDFDFDFDFD00ULL,
1398 0xFDFDFDFDFDFDFDFDULL
1399 },
1400 {
1401 0xFDFD000000000000ULL,
1402 0xFDFDFD0000000000ULL,
1403 0xFDFDFDFD00000000ULL,
1404 0xFDFDFDFDFD000000ULL,
1405 0xFDFDFDFDFDFD0000ULL,
1406 0xFDFDFDFDFDFDFD00ULL,
1407 0xFDFDFDFDFDFDFDFDULL,
1408 0xFDFDFDFDFDFDFDFDULL
1409 },
1410 {
1411 0xFDFDFD0000000000ULL,
1412 0xFDFDFDFD00000000ULL,
1413 0xFDFDFDFDFD000000ULL,
1414 0xFDFDFDFDFDFD0000ULL,
1415 0xFDFDFDFDFDFDFD00ULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL,
1418 0xFDFDFDFDFDFDFDFDULL
1419 },
1420 {
1421 0xFDFDFDFD00000000ULL,
1422 0xFDFDFDFDFD000000ULL,
1423 0xFDFDFDFDFDFD0000ULL,
1424 0xFDFDFDFDFDFDFD00ULL,
1425 0xFDFDFDFDFDFDFDFDULL,
1426 0xFDFDFDFDFDFDFDFDULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL
1429 },
1430 {
1431 0xFDFDFDFDFD000000ULL,
1432 0xFDFDFDFDFDFD0000ULL,
1433 0xFDFDFDFDFDFDFD00ULL,
1434 0xFDFDFDFDFDFDFDFDULL,
1435 0xFDFDFDFDFDFDFDFDULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL
1439 },
1440 {
1441 0xFDFDFDFDFDFD0000ULL,
1442 0xFDFDFDFDFDFDFD00ULL,
1443 0xFDFDFDFDFDFDFDFDULL,
1444 0xFDFDFDFDFDFDFDFDULL,
1445 0xFDFDFDFDFDFDFDFDULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL
1449 },
1450 {
1451 0xFDFDFDFDFDFDFD00ULL,
1452 0xFDFDFDFDFDFDFDFDULL,
1453 0xFDFDFDFDFDFDFDFDULL,
1454 0xFDFDFDFDFDFDFDFDULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL
1459 },
1460 {
1461 0xFDFDFDFDFDFDFDFDULL,
1462 0xFDFDFDFDFDFDFDFDULL,
1463 0xFDFDFDFDFDFDFDFDULL,
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL
1469 }
1470 },
1471 {
1472 {
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL
1481 },
1482 {
1483 0x0000000000000000ULL,
1484 0x0000000000000000ULL,
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x00000000000000FDULL
1491 },
1492 {
1493 0x0000000000000000ULL,
1494 0x0000000000000000ULL,
1495 0x0000000000000000ULL,
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x00000000000000FDULL,
1500 0x000000000000FDFDULL
1501 },
1502 {
1503 0x0000000000000000ULL,
1504 0x0000000000000000ULL,
1505 0x0000000000000000ULL,
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x00000000000000FDULL,
1509 0x000000000000FDFDULL,
1510 0x0000000000FDFDFDULL
1511 },
1512 {
1513 0x0000000000000000ULL,
1514 0x0000000000000000ULL,
1515 0x0000000000000000ULL,
1516 0x0000000000000000ULL,
1517 0x00000000000000FDULL,
1518 0x000000000000FDFDULL,
1519 0x0000000000FDFDFDULL,
1520 0x00000000FDFDFDFDULL
1521 },
1522 {
1523 0x0000000000000000ULL,
1524 0x0000000000000000ULL,
1525 0x0000000000000000ULL,
1526 0x00000000000000FDULL,
1527 0x000000000000FDFDULL,
1528 0x0000000000FDFDFDULL,
1529 0x00000000FDFDFDFDULL,
1530 0x000000FDFDFDFDFDULL
1531 },
1532 {
1533 0x0000000000000000ULL,
1534 0x0000000000000000ULL,
1535 0x00000000000000FDULL,
1536 0x000000000000FDFDULL,
1537 0x0000000000FDFDFDULL,
1538 0x00000000FDFDFDFDULL,
1539 0x000000FDFDFDFDFDULL,
1540 0x0000FDFDFDFDFDFDULL
1541 },
1542 {
1543 0x0000000000000000ULL,
1544 0x00000000000000FDULL,
1545 0x000000000000FDFDULL,
1546 0x0000000000FDFDFDULL,
1547 0x00000000FDFDFDFDULL,
1548 0x000000FDFDFDFDFDULL,
1549 0x0000FDFDFDFDFDFDULL,
1550 0x00FDFDFDFDFDFDFDULL
1551 },
1552 {
1553 0x00000000000000FDULL,
1554 0x000000000000FDFDULL,
1555 0x0000000000FDFDFDULL,
1556 0x00000000FDFDFDFDULL,
1557 0x000000FDFDFDFDFDULL,
1558 0x0000FDFDFDFDFDFDULL,
1559 0x00FDFDFDFDFDFDFDULL,
1560 0xFDFDFDFDFDFDFDFDULL
1561 },
1562 {
1563 0x000000000000FDFDULL,
1564 0x0000000000FDFDFDULL,
1565 0x00000000FDFDFDFDULL,
1566 0x000000FDFDFDFDFDULL,
1567 0x0000FDFDFDFDFDFDULL,
1568 0x00FDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL,
1570 0xFDFDFDFDFDFDFDFDULL
1571 },
1572 {
1573 0x0000000000FDFDFDULL,
1574 0x00000000FDFDFDFDULL,
1575 0x000000FDFDFDFDFDULL,
1576 0x0000FDFDFDFDFDFDULL,
1577 0x00FDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL
1581 },
1582 {
1583 0x00000000FDFDFDFDULL,
1584 0x000000FDFDFDFDFDULL,
1585 0x0000FDFDFDFDFDFDULL,
1586 0x00FDFDFDFDFDFDFDULL,
1587 0xFDFDFDFDFDFDFDFDULL,
1588 0xFDFDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL
1591 },
1592 {
1593 0x000000FDFDFDFDFDULL,
1594 0x0000FDFDFDFDFDFDULL,
1595 0x00FDFDFDFDFDFDFDULL,
1596 0xFDFDFDFDFDFDFDFDULL,
1597 0xFDFDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL
1601 },
1602 {
1603 0x0000FDFDFDFDFDFDULL,
1604 0x00FDFDFDFDFDFDFDULL,
1605 0xFDFDFDFDFDFDFDFDULL,
1606 0xFDFDFDFDFDFDFDFDULL,
1607 0xFDFDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL
1611 },
1612 {
1613 0x00FDFDFDFDFDFDFDULL,
1614 0xFDFDFDFDFDFDFDFDULL,
1615 0xFDFDFDFDFDFDFDFDULL,
1616 0xFDFDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL
1621 },
1622 {
1623 0xFDFDFDFDFDFDFDFDULL,
1624 0xFDFDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL,
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL
1631 }
1632 }
1633 };
1634
1635 int32_t black_opening_count=0;
1636 int32_t black_opening_x,black_opening_y;
1637 int32_t black_opening_shape;
1638
1639 484 int32_t choose_opening_shape()
1640 {
1641 // First, count how many bits are set
1642 484 int32_t numBits=0;
1643 int32_t bitCounter;
1644
1645
2/2
✓ Branch 0 taken 2420 times.
✓ Branch 1 taken 484 times.
2904 for(int32_t i=0; i<bosMAX; i++)
1646 {
1647
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 700 times.
2420 if(COOLSCROLL&(1<<i))
1648 700 numBits++;
1649 2420 }
1650
1651 // Shouldn't happen...
1652
1/2
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
484 if(numBits==0)
1653 return bosCIRCLE;
1654
1655 // Pick a bit
1656 484 bitCounter=zc_rand()%numBits+1;
1657
1658
2/2
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 26 times.
722 for(int32_t i=0; i<bosMAX; i++)
1659 {
1660 // If this bit is set, decrement the bit counter
1661
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 614 times.
696 if(COOLSCROLL&(1<<i))
1662 614 bitCounter--;
1663
1664 // When the counter hits 0, return a value based on
1665 // which bit it stopped on.
1666 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1667
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 238 times.
696 if(bitCounter==0)
1668 458 return i;
1669 238 }
1670
1671 // Shouldn't be necessary, but the compiler might complain, at least
1672 26 return bosCIRCLE;
1673 484 }
1674
1675 140 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1676 {
1677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1678
1679 140 int32_t w=256, h=224;
1680 140 int32_t blockrows=28, blockcolumns=32;
1681 140 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1682
1683
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 140 times.
4060 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1684 {
1685
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 3920 times.
129360 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1686 {
1687
2/2
✓ Branch 0 taken 67190 times.
✓ Branch 1 taken 58250 times.
125440 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1688 125440 }
1689 3920 }
1690
1691 140 black_opening_count = 66;
1692 140 black_opening_x = x;
1693 140 black_opening_y = y;
1694 140 lensclk = 0;
1695 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1696
1697
1698
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(black_opening_shape == bosFADEBLACK)
1699 {
1700 refreshTints();
1701 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1702 }
1703
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(wait)
1704 {
1705 FFCore.warpScriptCheck();
1706 for(int32_t i=0; i<66; i++)
1707 {
1708 draw_screen(tmpscr);
1709 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1710 advanceframe(true);
1711
1712 if(Quit)
1713 {
1714 break;
1715 }
1716 }
1717 }
1718 140 }
1719
1720 344 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1721 {
1722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1723
1724 344 int32_t w=256, h=224;
1725 344 int32_t blockrows=28, blockcolumns=32;
1726 344 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1727
1728
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 344 times.
9976 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1729 {
1730
2/2
✓ Branch 0 taken 308224 times.
✓ Branch 1 taken 9632 times.
317856 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1731 {
1732
2/2
✓ Branch 0 taken 148149 times.
✓ Branch 1 taken 160075 times.
308224 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1733 308224 }
1734 9632 }
1735
1736 344 black_opening_count = -66;
1737 344 black_opening_x = x;
1738 344 black_opening_y = y;
1739 344 lensclk = 0;
1740
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 if(black_opening_shape == bosFADEBLACK)
1741 {
1742 refreshTints();
1743 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1744 }
1745
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 234 times.
344 if(wait)
1746 {
1747 234 FFCore.warpScriptCheck();
1748
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 15444 times.
15678 for(int32_t i=0; i<66; i++)
1749 {
1750 15444 draw_screen(tmpscr);
1751 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1752 15444 advanceframe(true);
1753
1754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15444 times.
15444 if(Quit)
1755 {
1756 break;
1757 }
1758 15444 }
1759 234 }
1760 344 }
1761
1762 31944 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1763 {
1764 31944 clear_to_color(tmp_scr,BLACK);
1765 31944 int32_t w=256, h=224;
1766
1767
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28776 times.
31944 switch(black_opening_shape)
1768 {
1769 case bosOVAL:
1770 {
1771 858 double new_w=(w/2)+abs(w/2-x);
1772 858 double new_h=(h/2)+abs(h/2-y);
1773 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1774 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1775 858 break;
1776 }
1777
1778 case bosTRIANGLE:
1779 {
1780 660 double new_w=(w/2)+abs(w/2-x);
1781 660 double new_h=(h/2)+abs(h/2-y);
1782 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1783 660 double P2= (PI/2);
1784 660 double P23=(2*PI/3);
1785 660 double P43=(4*PI/3);
1786 660 double Pa= (-4*PI*a/(3*max_a));
1787 660 double angle=P2+Pa;
1788 660 double a0=angle;
1789 660 double a2=angle+P23;
1790 660 double a4=angle+P43;
1791 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1792 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1793 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1794 0);
1795 660 break;
1796 }
1797
1798 case bosSMAS:
1799 {
1800
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1801
1802
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1803 {
1804
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1805 {
1806 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1807
1808
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1809 {
1810 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1811
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1812 11827200 [linerow];
1813 11827200 ++triangleline;
1814
1815
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1816 {
1817 1478400 }
1818 11827200 }
1819 369600 }
1820 46200 }
1821
1822 1650 break;
1823 }
1824
1825 case bosFADEBLACK:
1826 {
1827 if(black_opening_count<0)
1828 {
1829 black_fade(zc_min(-black_opening_count,63));
1830 }
1831 else if(black_opening_count>0)
1832 {
1833 black_fade(63-zc_max(black_opening_count-3,0));
1834 }
1835 else black_fade(0);
1836 return; //no blitting from tmp_scr!
1837 }
1838
1839 28776 case bosCIRCLE:
1840 default:
1841 {
1842 28776 double new_w=(w/2)+abs(w/2-x);
1843 28776 double new_h=(h/2)+abs(h/2-y);
1844 28776 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1845 //circlefill(tmp_scr,x,y,a<<3,0);
1846 28776 circlefill(tmp_scr,x,y,r,0);
1847 28776 break;
1848 }
1849 }
1850
1851 31944 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1852 31944 }
1853
1854
1855 void black_fade(int32_t fadeamnt)
1856 {
1857 for(int32_t i=0; i < 0xEF; i++)
1858 {
1859 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1860 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1861 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1862 }
1863
1864 refreshpal = true;
1865 }
1866
1867 //----------------------------------------------------------------
1868
1869 12584867 bool item_disabled(int32_t item) //is this item disabled?
1870 {
1871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12584867 times.
12584867 return (item>=0 && game->items_off[item] != 0);
1872 }
1873
1874 4055993 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1875 {
1876
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 3998151 times.
4055993 if(current_item(item_type, true) >=item)
1877 {
1878 57842 return true;
1879 }
1880
1881 3998151 return false;
1882 4055993 }
1883
1884 16882319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1885 {
1886
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3042842 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1857470 times.
✓ Branch 6 taken 9035160 times.
✓ Branch 7 taken 2925848 times.
✓ Branch 8 taken 20999 times.
16882319 switch(item_type)
1887 {
1888 case itype_bomb:
1889 case itype_sbomb:
1890 {
1891 int32_t itemid = getItemID(itemsbuf, item_type, it);
1892
1893 if(itemid == -1)
1894 return false;
1895
1896 return (game->get_item(itemid));
1897 }
1898
1899 case itype_clock:
1900 {
1901 3042842 int32_t itemid = getItemID(itemsbuf, item_type, it);
1902
1903
2/4
✓ Branch 0 taken 3042842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3042842 times.
✗ Branch 3 not taken.
3042842 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1904 return (game->get_item(itemid));
1905 3042842 return Hero.getClock()?1:0;
1906 }
1907
1908 case itype_key:
1909 return (game->get_keys()>0);
1910
1911 case itype_magiccontainer:
1912 return (game->get_maxmagic()>=game->get_mp_per_block());
1913
1914 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1915 {
1916
1/3
✓ Branch 0 taken 1857470 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1857470 switch(it)
1917 {
1918 case -2:
1919 {
1920 for(int32_t i=0; i<MAXLEVELS; i++)
1921 {
1922 if(game->lvlitems[i]&liTRIFORCE)
1923 {
1924 return true;
1925 }
1926 }
1927
1928 return false;
1929 }
1930
1931 case -1:
1932 return (game->lvlitems[dlevel]&liTRIFORCE);
1933
1934 default:
1935
2/4
✓ Branch 0 taken 1857470 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1857470 times.
1857470 if(it>=0&&it<MAXLEVELS)
1936 {
1937 1857470 return (game->lvlitems[it]&liTRIFORCE);
1938 }
1939
1940 break;
1941 }
1942
1943 return 0;
1944 }
1945
1946 case itype_map: //it: -2=any, -1=current level, other=that level
1947 {
1948
1/3
✓ Branch 0 taken 9035160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
9035160 switch(it)
1949 {
1950 case -2:
1951 {
1952 for(int32_t i=0; i<MAXLEVELS; i++)
1953 {
1954 if(game->lvlitems[i]&liMAP)
1955 {
1956 return true;
1957 }
1958 }
1959
1960 return false;
1961 }
1962
1963 case -1:
1964 return (game->lvlitems[dlevel]&liMAP)!=0;
1965
1966 default:
1967
2/4
✓ Branch 0 taken 9035160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9035160 times.
9035160 if(it>=0&&it<MAXLEVELS)
1968 {
1969 9035160 return (game->lvlitems[it]&liMAP)!=0;
1970 }
1971
1972 break;
1973 }
1974
1975 return 0;
1976 }
1977
1978 case itype_compass: //it: -2=any, -1=current level, other=that level
1979 {
1980
1/3
✓ Branch 0 taken 2925848 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2925848 switch(it)
1981 {
1982 case -2:
1983 {
1984 for(int32_t i=0; i<MAXLEVELS; i++)
1985 {
1986 if(game->lvlitems[i]&liCOMPASS)
1987 {
1988 return true;
1989 }
1990 }
1991
1992 return false;
1993 }
1994
1995 case -1:
1996 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
1997
1998 default:
1999
2/4
✓ Branch 0 taken 2925848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2925848 times.
✗ Branch 3 not taken.
2925848 if(it>=0&&it<MAXLEVELS)
2000 {
2001 2925848 return (game->lvlitems[it]&liCOMPASS)!=0;
2002 }
2003
2004 break;
2005 }
2006 return 0;
2007 }
2008
2009 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2010 {
2011
1/3
✓ Branch 0 taken 20999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
20999 switch(it)
2012 {
2013 case -2:
2014 {
2015 for(int32_t i=0; i<MAXLEVELS; i++)
2016 {
2017 if(game->lvlitems[i]&liBOSSKEY)
2018 {
2019 return true;
2020 }
2021 }
2022
2023 return false;
2024 }
2025
2026 case -1:
2027 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2028
2029 default:
2030
2/4
✓ Branch 0 taken 20999 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20999 times.
20999 if(it>=0&&it<MAXLEVELS)
2031 {
2032 20999 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2033 }
2034 break;
2035 }
2036 return 0;
2037 }
2038
2039 default:
2040 //it=(1<<(it-1));
2041 /*if (item_type>=itype_max)
2042 {
2043 system_pal();
2044 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2045 game_pal();
2046
2047 return false;
2048 }*/
2049 int32_t itemid = getItemID(itemsbuf, item_type, it);
2050
2051 if(itemid == -1)
2052 return false;
2053
2054 return game->get_item(itemid);
2055 }
2056 16882319 }
2057
2058
2059 51785784 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2060 {
2061
9/9
✓ Branch 0 taken 3042842 times.
✓ Branch 1 taken 27443048 times.
✓ Branch 2 taken 3042842 times.
✓ Branch 3 taken 3042842 times.
✓ Branch 4 taken 3042842 times.
✓ Branch 5 taken 3042842 times.
✓ Branch 6 taken 3042842 times.
✓ Branch 7 taken 3042842 times.
✓ Branch 8 taken 3042842 times.
51785784 switch(item_type)
2062 {
2063 case itype_clock:
2064 {
2065 3042842 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2066
2067
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3042842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3042842 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2068 return itemsbuf[maxid].fam_type;
2069
2070 3042842 return has_item(itype_clock,1) ? 1 : 0;
2071 }
2072
2073 case itype_key:
2074 3042842 return game->get_keys();
2075
2076 case itype_lkey:
2077 3042842 return game->lvlkeys[get_dlevel()];
2078
2079 case itype_magiccontainer:
2080 3042842 return game->get_maxmagic()/game->get_mp_per_block();
2081
2082 case itype_triforcepiece:
2083 {
2084 3042842 int32_t count=0;
2085
2086
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2087 {
2088 1557935104 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2089 1557935104 }
2090
2091 3042842 return count;
2092 }
2093
2094 case itype_map:
2095 {
2096 3042842 int32_t count=0;
2097
2098
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2099 {
2100 1557935104 count+=(game->lvlitems[i]&liMAP)?1:0;
2101 1557935104 }
2102
2103 3042842 return count;
2104 }
2105
2106 case itype_compass:
2107 {
2108 3042842 int32_t count=0;
2109
2110
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2111 {
2112 1557935104 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2113 1557935104 }
2114
2115 3042842 return count;
2116 }
2117
2118 case itype_bosskey:
2119 {
2120 3042842 int32_t count=0;
2121
2122
2/2
✓ Branch 0 taken 1557935104 times.
✓ Branch 1 taken 3042842 times.
1560977946 for(int32_t i=0; i<MAXLEVELS; i++)
2123 {
2124 1557935104 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2125 1557935104 }
2126
2127 3042842 return count;
2128 }
2129
2130 default:
2131 27443048 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2132
2133
2/2
✓ Branch 0 taken 5849832 times.
✓ Branch 1 taken 21593216 times.
27443048 if(maxid == -1)
2134 21593216 return 0;
2135
2136 5849832 return itemsbuf[maxid].fam_type;
2137 }
2138 51785784 }
2139
2140 47729791 int32_t current_item(int32_t item_type) //item currently being used
2141 {
2142 47729791 return current_item(item_type, true);
2143 }
2144
2145 28 std::map<int32_t, int32_t> itemcache;
2146
2147 // Not actually used by anything at the moment...
2148 void removeFromItemCache(int32_t itemid)
2149 {
2150 itemcache.erase(itemid);
2151 }
2152
2153 14211 void flushItemCache()
2154 {
2155 14211 itemcache.clear();
2156
2157 //also fix the active subscreen if items were deleted -DD
2158
1/2
✓ Branch 0 taken 14211 times.
✗ Branch 1 not taken.
14211 if(game != NULL)
2159 {
2160 14211 verifyBothWeapons();
2161 14211 load_Sitems(&QMisc);
2162 14211 }
2163 14211 }
2164
2165 // This is used often, so it should be as direct as possible.
2166 1705007344 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2167 {
2168
2/2
✓ Branch 0 taken 1666686329 times.
✓ Branch 1 taken 38321015 times.
1705007344 if(jinx_check)
2169 {
2170
4/4
✓ Branch 0 taken 23802462 times.
✓ Branch 1 taken 14518553 times.
✓ Branch 2 taken 20395436 times.
✓ Branch 3 taken 3407026 times.
38321015 if(!(HeroSwordClk() || HeroItemClk()))
2171 20395436 jinx_check = false; //not jinxed
2172 38321015 }
2173
4/4
✓ Branch 0 taken 1687930273 times.
✓ Branch 1 taken 17077071 times.
✓ Branch 2 taken 17787258 times.
✓ Branch 3 taken 1670143015 times.
1705007344 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2174 {
2175 1670143015 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2176
2177
2/2
✓ Branch 0 taken 1662889395 times.
✓ Branch 1 taken 7253620 times.
1670143015 if(res != itemcache.end())
2178 1662889395 return res->second;
2179 7253620 }
2180
2181 42117949 int32_t result = -1;
2182 42117949 int32_t highestlevel = -1;
2183
2184
2/2
✓ Branch 0 taken 10782194944 times.
✓ Branch 1 taken 42117949 times.
10824312893 for(int32_t i=0; i<MAXITEMS; i++)
2185 {
2186
5/6
✓ Branch 0 taken 839070580 times.
✓ Branch 1 taken 9943124364 times.
✓ Branch 2 taken 12110143 times.
✓ Branch 3 taken 826960437 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12110143 times.
10782194944 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2187 {
2188
4/4
✓ Branch 0 taken 3090127 times.
✓ Branch 1 taken 9020016 times.
✓ Branch 2 taken 954641 times.
✓ Branch 3 taken 11155502 times.
12110143 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2189 {
2190 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2191
2/2
✓ Branch 0 taken 11155382 times.
✓ Branch 1 taken 120 times.
11155502 if(!checkmagiccost(i))
2192 {
2193
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2194 12 }
2195 11155394 }
2196
6/6
✓ Branch 0 taken 10275202 times.
✓ Branch 1 taken 1834833 times.
✓ Branch 2 taken 181578 times.
✓ Branch 3 taken 1653255 times.
✓ Branch 4 taken 1165337 times.
✓ Branch 5 taken 669496 times.
12110035 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 669496 times.
669496 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2199 669496 continue;
2200 }
2201
2202
2/2
✓ Branch 0 taken 178745 times.
✓ Branch 1 taken 11261794 times.
11440539 if(itemsbuf[i].fam_type >= highestlevel)
2203 {
2204 11261794 highestlevel = itemsbuf[i].fam_type;
2205 11261794 result=i;
2206 11261794 }
2207 11440539 }
2208 10781525340 }
2209
2210
2/2
✓ Branch 0 taken 17925579 times.
✓ Branch 1 taken 24192370 times.
42117949 if(!jinx_check) //Can't cache jinx_check results
2211 24192370 itemcache[itemtype] = result;
2212 42117949 return result;
2213 1705007344 }
2214
2215 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2216 1687322780 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2217 {
2218 1687322780 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2219
2/2
✓ Branch 0 taken 20636451 times.
✓ Branch 1 taken 1666686329 times.
1687322780 if(!jinx_check) //If not already a jinx-immune-only check...
2220 {
2221 //And the player IS jinxed...
2222
4/4
✓ Branch 0 taken 1652359129 times.
✓ Branch 1 taken 14327200 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 1649001765 times.
1666686329 if(HeroSwordClk() || HeroItemClk())
2223 {
2224 //Then do a jinx-immune-only check here
2225 17684564 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2226 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2227 //Should NOT need a compat rule, as this should always return -1 in old quests.
2228
2/2
✓ Branch 0 taken 799716 times.
✓ Branch 1 taken 16884848 times.
17684564 if(ret2 > -1) return ret2;
2229 16884848 }
2230 1665886613 }
2231 1686523064 return ret;
2232 1687322780 }
2233 11378378 int32_t current_item_power(int32_t itemtype)
2234 {
2235 11378378 int32_t result = current_item_id(itemtype,true);
2236
2/2
✓ Branch 0 taken 8098941 times.
✓ Branch 1 taken 3279437 times.
11378378 return (result<0) ? 0 : itemsbuf[result].power;
2237 }
2238
2239 5 int32_t heart_container_id()
2240 {
2241
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 for(int32_t i=0; i<MAXITEMS; i++)
2242 {
2243
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 140 times.
145 if(itemsbuf[i].family == itype_heartcontainer)
2244 {
2245 5 return i;
2246 }
2247 140 }
2248 return -1;
2249 5 }
2250
2251 3042842 int32_t item_tile_mod()
2252 {
2253 3042842 int32_t tile=0;
2254
2255
2/2
✓ Branch 0 taken 930334 times.
✓ Branch 1 taken 2112508 times.
3042842 if(game->get_bombs())
2256 {
2257 2112508 int32_t itemid = current_item_id(itype_bomb,false);
2258
3/4
✓ Branch 0 taken 2031449 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2031449 times.
2112508 if(itemid > -1 && checkbunny(itemid))
2259 2031449 tile+=itemsbuf[itemid].ltm;
2260 2112508 }
2261
2262
2/2
✓ Branch 0 taken 2604053 times.
✓ Branch 1 taken 438789 times.
3042842 if(game->get_sbombs())
2263 {
2264 438789 int32_t itemid = current_item_id(itype_sbomb,false);
2265
3/4
✓ Branch 0 taken 437361 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 437361 times.
438789 if(itemid > -1 && checkbunny(itemid))
2266 437361 tile+=itemsbuf[itemid].ltm;
2267 438789 }
2268
2269
2/2
✓ Branch 0 taken 2965573 times.
✓ Branch 1 taken 77269 times.
3042842 if(current_item(itype_clock))
2270 {
2271 77269 int32_t itemid =
2272
1/2
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
77269 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2273 ? iClock
2274 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2275
2/4
✓ Branch 0 taken 77269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77269 times.
77269 if(itemid > -1 && checkbunny(itemid))
2276 77269 tile+=itemsbuf[itemid].ltm;
2277 77269 }
2278
2279
2/2
✓ Branch 0 taken 2430570 times.
✓ Branch 1 taken 612272 times.
3042842 if(current_item(itype_key))
2280 {
2281 612272 int32_t itemid =
2282
1/2
✓ Branch 0 taken 612272 times.
✗ Branch 1 not taken.
612272 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2283 ? iKey
2284 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2285
2/4
✓ Branch 0 taken 612272 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 612272 times.
612272 if(itemid > -1 && checkbunny(itemid))
2286 612272 tile+=itemsbuf[itemid].ltm;
2287 612272 }
2288
2289
2/2
✓ Branch 0 taken 2883589 times.
✓ Branch 1 taken 159253 times.
3042842 if(current_item(itype_lkey))
2290 {
2291 159253 int32_t itemid =
2292
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2293 ? iLevelKey
2294 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2295
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2296 159253 tile+=itemsbuf[itemid].ltm;
2297 159253 }
2298
2299
2/2
✓ Branch 0 taken 836888 times.
✓ Branch 1 taken 2205954 times.
3042842 if(current_item(itype_map))
2300 {
2301 2205954 int32_t itemid =
2302
2/2
✓ Branch 0 taken 2205168 times.
✓ Branch 1 taken 786 times.
2205954 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2303 ? iMap
2304 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2305
2/4
✓ Branch 0 taken 2205954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2205954 times.
2205954 if(itemid > -1 && checkbunny(itemid))
2306 2205954 tile+=itemsbuf[itemid].ltm;
2307 2205954 }
2308
2309
2/2
✓ Branch 0 taken 754185 times.
✓ Branch 1 taken 2288657 times.
3042842 if(current_item(itype_compass))
2310 {
2311 2288657 int32_t itemid =
2312
2/2
✓ Branch 0 taken 2207598 times.
✓ Branch 1 taken 81059 times.
2288657 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2313 ? iCompass
2314 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2315
2/4
✓ Branch 0 taken 2288657 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2288657 times.
2288657 if(itemid > -1 && checkbunny(itemid))
2316 2288657 tile+=itemsbuf[itemid].ltm;
2317 2288657 }
2318
2319
2/2
✓ Branch 0 taken 1232480 times.
✓ Branch 1 taken 1810362 times.
3042842 if(current_item(itype_bosskey))
2320 {
2321 1810362 int32_t itemid =
2322
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2323 ? iBossKey
2324 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2325
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2326 1810362 tile+=itemsbuf[itemid].ltm;
2327 1810362 }
2328
2329
2/2
✓ Branch 0 taken 2084333 times.
✓ Branch 1 taken 958509 times.
3042842 if(current_item(itype_magiccontainer))
2330 {
2331 958509 int32_t itemid =
2332
2/2
✓ Branch 0 taken 865294 times.
✓ Branch 1 taken 93215 times.
958509 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2333 ? iMagicC
2334 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2335
3/4
✓ Branch 0 taken 958509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 956639 times.
958509 if(itemid > -1 && checkbunny(itemid))
2336 956639 tile+=itemsbuf[itemid].ltm;
2337 958509 }
2338
2339
2/2
✓ Branch 0 taken 1066255 times.
✓ Branch 1 taken 1976587 times.
3042842 if(current_item(itype_triforcepiece))
2340 {
2341 1976587 int32_t itemid =
2342
1/2
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
1976587 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2343 ? iTriforce
2344 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2345
2/4
✓ Branch 0 taken 1976587 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1976587 times.
1976587 if(itemid > -1 && checkbunny(itemid))
2346 1976587 tile+=itemsbuf[itemid].ltm;
2347 1976587 }
2348
2349
2/2
✓ Branch 0 taken 3042842 times.
✓ Branch 1 taken 1557935104 times.
1560977946 for(int32_t i=0; i<itype_max; i++)
2350 {
2351
2/2
✓ Branch 0 taken 1501633024 times.
✓ Branch 1 taken 56302080 times.
1557935104 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2352 {
2353
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2354 {
2355 case itype_bomb:
2356 case itype_sbomb:
2357 case itype_clock:
2358 case itype_key:
2359 case itype_lkey:
2360 case itype_map:
2361 case itype_compass:
2362 case itype_bosskey:
2363 case itype_magiccontainer:
2364 case itype_triforcepiece:
2365 1099650 continue; //already handled
2366 }
2367 55202430 }
2368 1556835454 int32_t itemid = current_item_id(i,false);
2369
2/2
✓ Branch 0 taken 1553792612 times.
✓ Branch 1 taken 3042842 times.
1556835454 if(i == itype_shield)
2370 3042842 itemid = getCurrentShield(false);
2371
2372
4/4
✓ Branch 0 taken 42239563 times.
✓ Branch 1 taken 1514595891 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 42138582 times.
1556835454 if(itemid < 0 || !checkbunny(itemid))
2373 1514696872 continue;
2374
2375 42138582 itemdata const& itm = itemsbuf[itemid];
2376
2377
2/2
✓ Branch 0 taken 39673262 times.
✓ Branch 1 taken 2465320 times.
42138582 switch(itm.family)
2378 {
2379 case itype_shield:
2380
1/2
✓ Branch 0 taken 2465320 times.
✗ Branch 1 not taken.
2465320 if(itm.flags & ITEM_FLAG9) //active shield
2381 {
2382 if(!usingActiveShield(itemid))
2383 {
2384 tile+=itm.misc6; //'Inactive PTM'
2385 continue;
2386 }
2387 }
2388 2465320 break;
2389 }
2390
2391 42138582 tile+=itm.ltm;
2392 42138582 }
2393
2394 3042842 return tile;
2395 }
2396
2397 3042842 int32_t bunny_tile_mod()
2398 {
2399
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 3040972 times.
3042842 if(Hero.BunnyClock())
2400 {
2401 1870 return game->get_bunny_ltm();
2402 }
2403 3040972 return 0;
2404 3042842 }
2405
2406 // Hints are drawn on a separate layer to combo reveals.
2407 12952 void draw_lens_under(BITMAP *dest, bool layer)
2408 {
2409 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2410 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2411 //Lens flag 3: Don't show armos/chest/dive items
2412 //Lens flag 4: Show Raft Paths
2413 //Lens flag 5: Show Invisible Enemies
2414
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 12496 times.
✓ Branch 2 taken 6248 times.
✓ Branch 3 taken 6248 times.
12952 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2415
2416 12952 int32_t strike_hint_table[11]=
2417 {
2418 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2419 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2420 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2421 };
2422
2423 // int32_t page = tmpscr->cpage;
2424 {
2425 12952 int32_t blink_rate=flash_reduction_enabled()?6:1;
2426 // int32_t temptimer=0;
2427 12952 int32_t tempitem, tempweapon=0;
2428 12952 strike_hint=strike_hint_table[strike_hint_counter];
2429
2430
2/2
✓ Branch 0 taken 12562 times.
✓ Branch 1 taken 390 times.
12952 if(strike_hint_timer>32)
2431 {
2432 390 strike_hint_timer=0;
2433 390 strike_hint_counter=((strike_hint_counter+1)%11);
2434 390 }
2435
2436 12952 ++strike_hint_timer;
2437
2438
2/2
✓ Branch 0 taken 2279552 times.
✓ Branch 1 taken 12952 times.
2292504 for(int32_t i=0; i<176; i++)
2439 {
2440 2279552 int32_t x = (i & 15) << 4;
2441 2279552 int32_t y = (i & 0xF0) + playing_field_offset;
2442 2279552 int32_t tempitemx=-16, tempitemy=-16;
2443 2279552 int32_t tempweaponx=-16, tempweapony=-16;
2444
2445
2/2
✓ Branch 0 taken 4559104 times.
✓ Branch 1 taken 2279552 times.
6838656 for(int32_t iter=0; iter<2; ++iter)
2446 {
2447 4559104 int32_t checkflag=0;
2448
2449
2/2
✓ Branch 0 taken 2279552 times.
✓ Branch 1 taken 2279552 times.
4559104 if(iter==0)
2450 {
2451 2279552 checkflag=combobuf[tmpscr->data[i]].flag;
2452 2279552 }
2453 else
2454 {
2455 2279552 checkflag=tmpscr->sflag[i];
2456 }
2457
2458
2/2
✓ Branch 0 taken 4558006 times.
✓ Branch 1 taken 1098 times.
4559104 if(checkflag==mfSTRIKE)
2459 {
2460
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2461 {
2462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2463 906 }
2464 else
2465 {
2466 192 checkflag = strike_hint;
2467 }
2468 1098 }
2469
2470
19/36
✓ Branch 0 taken 4520712 times.
✓ Branch 1 taken 2638 times.
✓ Branch 2 taken 2808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28392 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
4559104 switch(checkflag)
2471 {
2472 case 0:
2473 case mfZELDA:
2474 case mfPUSHED:
2475 case mfENEMY0:
2476 case mfENEMY1:
2477 case mfENEMY2:
2478 case mfENEMY3:
2479 case mfENEMY4:
2480 case mfENEMY5:
2481 case mfENEMY6:
2482 case mfENEMY7:
2483 case mfENEMY8:
2484 case mfENEMY9:
2485 case mfSINGLE:
2486 case mfSINGLE16:
2487 case mfNOENEMY:
2488 case mfTRAP_H:
2489 case mfTRAP_V:
2490 case mfTRAP_4:
2491 case mfTRAP_LR:
2492 case mfTRAP_UD:
2493 case mfNOGROUNDENEMY:
2494 case mfNOBLOCKS:
2495 case mfSCRIPT1:
2496 case mfSCRIPT2:
2497 case mfSCRIPT3:
2498 case mfSCRIPT4:
2499 case mfSCRIPT5:
2500 case mfSCRIPT6:
2501 case mfSCRIPT7:
2502 case mfSCRIPT8:
2503 case mfSCRIPT9:
2504 case mfSCRIPT10:
2505 case mfSCRIPT11:
2506 case mfSCRIPT12:
2507 case mfSCRIPT13:
2508 case mfSCRIPT14:
2509 case mfSCRIPT15:
2510 case mfSCRIPT16:
2511 case mfSCRIPT17:
2512 case mfSCRIPT18:
2513 case mfSCRIPT19:
2514 case mfSCRIPT20:
2515 case mfPITHOLE:
2516 case mfPITFALLFLOOR:
2517 case mfLAVA:
2518 case mfICE:
2519 case mfICEDAMAGE:
2520 case mfDAMAGE1:
2521 case mfDAMAGE2:
2522 case mfDAMAGE4:
2523 case mfDAMAGE8:
2524 case mfDAMAGE16:
2525 case mfDAMAGE32:
2526 case mfFREEZEALL:
2527 case mfFREZEALLANSFFCS:
2528 case mfFREEZEFFCSOLY:
2529 case mfSCRITPTW1TRIG:
2530 case mfSCRITPTW2TRIG:
2531 case mfSCRITPTW3TRIG:
2532 case mfSCRITPTW4TRIG:
2533 case mfSCRITPTW5TRIG:
2534 case mfSCRITPTW6TRIG:
2535 case mfSCRITPTW7TRIG:
2536 case mfSCRITPTW8TRIG:
2537 case mfSCRITPTW9TRIG:
2538 case mfSCRITPTW10TRIG:
2539 case mfTROWEL:
2540 case mfTROWELNEXT:
2541 case mfTROWELSPECIALITEM:
2542 case mfSLASHPOT:
2543 case mfLIFTPOT:
2544 case mfLIFTORSLASH:
2545 case mfLIFTROCK:
2546 case mfLIFTROCKHEAVY:
2547 case mfDROPITEM:
2548 case mfSPECIALITEM:
2549 case mfDROPKEY:
2550 case mfDROPLKEY:
2551 case mfDROPCOMPASS:
2552 case mfDROPMAP:
2553 case mfDROPBOSSKEY:
2554 case mfSPAWNNPC:
2555 case mfSWITCHHOOK:
2556 case mfSIDEVIEWLADDER:
2557 case mfSIDEVIEWPLATFORM:
2558 case mfNOENEMYSPAWN:
2559 case mfENEMYALL:
2560 case mfNOMIRROR:
2561 case mfUNSAFEGROUND:
2562 case mf168:
2563 case mf169:
2564 case mf170:
2565 case mf171:
2566 case mf172:
2567 case mf173:
2568 case mf174:
2569 case mf175:
2570 case mf176:
2571 case mf177:
2572 case mf178:
2573 case mf179:
2574 case mf180:
2575 case mf181:
2576 case mf182:
2577 case mf183:
2578 case mf184:
2579 case mf185:
2580 case mf186:
2581 case mf187:
2582 case mf188:
2583 case mf189:
2584 case mf190:
2585 case mf191:
2586 case mf192:
2587 case mf193:
2588 case mf194:
2589 case mf195:
2590 case mf196:
2591 case mf197:
2592 case mf198:
2593 case mf199:
2594 case mf200:
2595 case mf201:
2596 case mf202:
2597 case mf203:
2598 case mf204:
2599 case mf205:
2600 case mf206:
2601 case mf207:
2602 case mf208:
2603 case mf209:
2604 case mf210:
2605 case mf211:
2606 case mf212:
2607 case mf213:
2608 case mf214:
2609 case mf215:
2610 case mf216:
2611 case mf217:
2612 case mf218:
2613 case mf219:
2614 case mf220:
2615 case mf221:
2616 case mf222:
2617 case mf223:
2618 case mf224:
2619 case mf225:
2620 case mf226:
2621 case mf227:
2622 case mf228:
2623 case mf229:
2624 case mf230:
2625 case mf231:
2626 case mf232:
2627 case mf233:
2628 case mf234:
2629 case mf235:
2630 case mf236:
2631 case mf237:
2632 case mf238:
2633 case mf239:
2634 case mf240:
2635 case mf241:
2636 case mf242:
2637 case mf243:
2638 case mf244:
2639 case mf245:
2640 case mf246:
2641 case mf247:
2642 case mf248:
2643 case mf249:
2644 case mf250:
2645 case mf251:
2646 case mf252:
2647 case mf253:
2648 case mf254:
2649 case mfEXTENDED:
2650 4520712 break;
2651
2652 case mfPUSHUD:
2653 case mfPUSHLR:
2654 case mfPUSH4:
2655 case mfPUSHU:
2656 case mfPUSHD:
2657 case mfPUSHL:
2658 case mfPUSHR:
2659 case mfPUSHUDNS:
2660 case mfPUSHLRNS:
2661 case mfPUSH4NS:
2662 case mfPUSHUNS:
2663 case mfPUSHDNS:
2664 case mfPUSHLNS:
2665 case mfPUSHRNS:
2666 case mfPUSHUDINS:
2667 case mfPUSHLRINS:
2668 case mfPUSH4INS:
2669 case mfPUSHUINS:
2670 case mfPUSHDINS:
2671 case mfPUSHLINS:
2672 case mfPUSHRINS:
2673
3/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
2638 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2674
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1319 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1319 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2675 {
2676 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2677 }
2678
2679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2638 times.
2638 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2680
3/6
✓ Branch 0 taken 2064 times.
✓ Branch 1 taken 574 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 574 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2638 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2681 {
2682
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 1032 times.
2064 if(hints)
2683 {
2684
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2685 {
2686 case cPUSH_HEAVY:
2687 case cPUSH_HW:
2688 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2689 72 tempitemx=x, tempitemy=y;
2690
2691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2692 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2693
2694 72 break;
2695
2696 case cPUSH_HEAVY2:
2697 case cPUSH_HW2:
2698 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2699 63 tempitemx=x, tempitemy=y;
2700
2701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2702 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2703
2704 63 break;
2705 }
2706 1032 }
2707 2064 }
2708
2709 2638 break;
2710
2711 case mfWHISTLE:
2712 if(hints)
2713 {
2714 tempitem=getItemID(itemsbuf,itype_whistle,1);
2715
2716 if(tempitem<0) break;
2717
2718 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2719 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2720 {
2721 tempitemx=x;
2722 tempitemy=y;
2723 }
2724
2725 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2726 }
2727
2728 break;
2729
2730 //Why is this here?
2731 case mfFAIRY:
2732 case mfMAGICFAIRY:
2733 case mfALLFAIRY:
2734 if(hints)
2735 {
2736 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2737
2738 if(tempitem < 0) break;
2739
2740 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2741 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2742 {
2743 tempitemx=x;
2744 tempitemy=y;
2745 }
2746
2747 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2748 }
2749
2750 break;
2751
2752 case mfBCANDLE:
2753
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2754 {
2755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2756 252 }
2757 else
2758 {
2759 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2760
2761
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2762
2763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2764
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2765 {
2766 189 tempitemx=x;
2767 189 tempitemy=y;
2768 189 }
2769
2770 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2771 }
2772
2773 504 break;
2774
2775 case mfRCANDLE:
2776 if(!hints)
2777 {
2778 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2779 }
2780 else
2781 {
2782 tempitem=getItemID(itemsbuf,itype_candle,2);
2783
2784 if(tempitem<0) break;
2785
2786 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2787 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2788 {
2789 tempitemx=x;
2790 tempitemy=y;
2791 }
2792
2793 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2794 }
2795
2796 break;
2797
2798 case mfWANDFIRE:
2799 if(!hints)
2800 {
2801 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2802 }
2803 else
2804 {
2805 tempitem=getItemID(itemsbuf,itype_wand,1);
2806
2807 if(tempitem<0) break;
2808
2809 tempweapon=wFire;
2810
2811 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2812 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2813 {
2814 tempitemx=x;
2815 tempitemy=y;
2816 }
2817 else
2818 {
2819 tempweaponx=x;
2820 tempweapony=y;
2821 }
2822
2823 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2824 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2825 }
2826
2827 break;
2828
2829 case mfDINSFIRE:
2830 if(!hints)
2831 {
2832 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2833 }
2834 else
2835 {
2836 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2837
2838 if(tempitem<0) break;
2839
2840 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2841 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2842 {
2843 tempitemx=x;
2844 tempitemy=y;
2845 }
2846
2847 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2848 }
2849
2850 break;
2851
2852 case mfARROW:
2853
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2854 {
2855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2856 732 }
2857 else
2858 {
2859 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2860
2861
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2862
2863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2864
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2865 {
2866 61 tempitemx=x;
2867 61 tempitemy=y;
2868 61 }
2869
2870 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2871 }
2872
2873 814 break;
2874
2875 case mfSARROW:
2876 if(!hints)
2877 {
2878 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2879 }
2880 else
2881 {
2882 tempitem=getItemID(itemsbuf,itype_arrow,2);
2883
2884 if(tempitem<0) break;
2885
2886 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2887 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2888 {
2889 tempitemx=x;
2890 tempitemy=y;
2891 }
2892
2893 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2894 }
2895
2896 break;
2897
2898 case mfGARROW:
2899 if(!hints)
2900 {
2901 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2902 }
2903 else
2904 {
2905 tempitem=getItemID(itemsbuf,itype_arrow,3);
2906
2907 if(tempitem<0) break;
2908
2909 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2910 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2911 {
2912 tempitemx=x;
2913 tempitemy=y;
2914 }
2915
2916 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2917 }
2918
2919 break;
2920
2921 case mfBOMB:
2922
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
2923 {
2924 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2925 }
2926 else
2927 {
2928 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2929 17 tempweapon = wLitBomb;
2930
2931 //if (tempitem<0) break;
2932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2933
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2934 {
2935 12 tempweaponx=x;
2936 12 tempweapony=y;
2937 12 }
2938
2939 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2940 }
2941
2942 17 break;
2943
2944 case mfSBOMB:
2945
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
2946 {
2947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2948 48 }
2949 else
2950 {
2951 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2952 //if (tempitem<0) break;
2953 48 tempweapon = wLitSBomb;
2954
2955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2956
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2957 {
2958 36 tempweaponx=x;
2959 36 tempweapony=y;
2960 36 }
2961
2962 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2963 }
2964
2965 96 break;
2966
2967 case mfARMOS_SECRET:
2968
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
2969 {
2970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2971 12 }
2972 24 break;
2973
2974 case mfBRANG:
2975
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
2976 {
2977 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2978 }
2979 else
2980 {
2981 5 tempitem=getItemID(itemsbuf,itype_brang,1);
2982
2983
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
2984
2985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2986
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2987 {
2988 4 tempitemx=x;
2989 4 tempitemy=y;
2990 4 }
2991
2992 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2993 }
2994
2995 5 break;
2996
2997 case mfMBRANG:
2998 if(!hints)
2999 {
3000 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3001 }
3002 else
3003 {
3004 tempitem=getItemID(itemsbuf,itype_brang,2);
3005
3006 if(tempitem<0) break;
3007
3008 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3009 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3010 {
3011 tempitemx=x;
3012 tempitemy=y;
3013 }
3014
3015 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3016 }
3017
3018 break;
3019
3020 case mfFBRANG:
3021 if(!hints)
3022 {
3023 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3024 }
3025 else
3026 {
3027 tempitem=getItemID(itemsbuf,itype_brang,3);
3028
3029 if(tempitem<0) break;
3030
3031 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3032 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3033 {
3034 tempitemx=x;
3035 tempitemy=y;
3036 }
3037
3038 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3039 }
3040
3041 break;
3042
3043 case mfWANDMAGIC:
3044 if(!hints)
3045 {
3046 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3047 }
3048 else
3049 {
3050 tempitem=getItemID(itemsbuf,itype_wand,1);
3051
3052 if(tempitem<0) break;
3053
3054 tempweapon=itemsbuf[tempitem].wpn3;
3055
3056 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3057 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3058 {
3059 tempitemx=x;
3060 tempitemy=y;
3061 }
3062 else
3063 {
3064 tempweaponx=x;
3065 tempweapony=y;
3066 --lens_hint_weapon[wMagic][4];
3067
3068 if(lens_hint_weapon[wMagic][4]<-8)
3069 {
3070 lens_hint_weapon[wMagic][4]=8;
3071 }
3072 }
3073
3074 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3075 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3076 }
3077
3078 break;
3079
3080 case mfREFMAGIC:
3081
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3082 {
3083 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3084 }
3085 else
3086 {
3087 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3088
3089
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3090
3091 16 tempweapon=ewMagic;
3092
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3094
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3095 {
3096 13 tempitemx=x;
3097 13 tempitemy=y;
3098 13 }
3099 else
3100 {
3101 3 tempweaponx=x;
3102 3 tempweapony=y;
3103
3104
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3105 {
3106 1 --lens_hint_weapon[ewMagic][4];
3107 1 }
3108 else
3109 {
3110 2 ++lens_hint_weapon[ewMagic][4];
3111 }
3112
3113
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3114 {
3115 lens_hint_weapon[ewMagic][2]=up;
3116 }
3117
3118
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3119 {
3120 2 lens_hint_weapon[ewMagic][2]=down;
3121 2 }
3122 }
3123
3124 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3125 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3126 }
3127
3128 16 break;
3129
3130 case mfREFFIREBALL:
3131
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3132 {
3133 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3134 }
3135 else
3136 {
3137 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3138
3139
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3140
3141 16 tempweapon=ewFireball;
3142
3143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3144
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3145 {
3146 12 tempitemx=x;
3147 12 tempitemy=y;
3148 12 tempweaponx=x;
3149 12 tempweapony=y;
3150 12 ++lens_hint_weapon[ewFireball][3];
3151
3152
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3153 {
3154 1 lens_hint_weapon[ewFireball][3]=-8;
3155 1 lens_hint_weapon[ewFireball][4]=8;
3156 1 }
3157
3158
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3159 {
3160 8 ++lens_hint_weapon[ewFireball][4];
3161 8 }
3162 else
3163 {
3164 4 --lens_hint_weapon[ewFireball][4];
3165 }
3166 12 }
3167
3168 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3169 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3170 }
3171
3172 16 break;
3173
3174 case mfSWORD:
3175
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3176 {
3177 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3178 }
3179 else
3180 {
3181 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3182
3183
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3184
3185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3186
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3187 {
3188 5 tempitemx=x;
3189 5 tempitemy=y;
3190 5 }
3191
3192 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3193 }
3194
3195 7 break;
3196
3197 case mfWSWORD:
3198 if(!hints)
3199 {
3200 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3201 }
3202 else
3203 {
3204 tempitem=getItemID(itemsbuf,itype_sword,2);
3205
3206 if(tempitem<0) break;
3207
3208 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3209 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3210 {
3211 tempitemx=x;
3212 tempitemy=y;
3213 }
3214
3215 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3216 }
3217
3218 break;
3219
3220 case mfMSWORD:
3221 if(!hints)
3222 {
3223 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3224 }
3225 else
3226 {
3227 tempitem=getItemID(itemsbuf,itype_sword,3);
3228
3229 if(tempitem<0) break;
3230
3231 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3232 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3233 {
3234 tempitemx=x;
3235 tempitemy=y;
3236 }
3237
3238 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3239 }
3240
3241 break;
3242
3243 case mfXSWORD:
3244 if(!hints)
3245 {
3246 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3247 }
3248 else
3249 {
3250 tempitem=getItemID(itemsbuf,itype_sword,4);
3251
3252 if(tempitem<0) break;
3253
3254 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3255 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3256 {
3257 tempitemx=x;
3258 tempitemy=y;
3259 }
3260
3261 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3262 }
3263
3264 break;
3265
3266 case mfSWORDBEAM:
3267
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3268 {
3269 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3270 }
3271 else
3272 {
3273 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3274
3275
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3276
3277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3278
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3279 {
3280 11 tempitemx=x;
3281 11 tempitemy=y;
3282 11 }
3283
3284 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3285 }
3286
3287 16 break;
3288
3289 case mfWSWORDBEAM:
3290 if(!hints)
3291 {
3292 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3293 }
3294 else
3295 {
3296 tempitem=getItemID(itemsbuf,itype_sword,2);
3297
3298 if(tempitem<0) break;
3299
3300 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3301 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3302 {
3303 tempitemx=x;
3304 tempitemy=y;
3305 }
3306
3307 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3308 }
3309
3310 break;
3311
3312 case mfMSWORDBEAM:
3313 if(!hints)
3314 {
3315 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3316 }
3317 else
3318 {
3319 tempitem=getItemID(itemsbuf,itype_sword,3);
3320
3321 if(tempitem<0) break;
3322
3323 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3324 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3325 {
3326 tempitemx=x;
3327 tempitemy=y;
3328 }
3329
3330 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3331 }
3332
3333 break;
3334
3335 case mfXSWORDBEAM:
3336 if(!hints)
3337 {
3338 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3339 }
3340 else
3341 {
3342 tempitem=getItemID(itemsbuf,itype_sword,4);
3343
3344 if(tempitem<0) break;
3345
3346 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3347 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3348 {
3349 tempitemx=x;
3350 tempitemy=y;
3351 }
3352
3353 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3354 }
3355
3356 break;
3357
3358 case mfHOOKSHOT:
3359
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3360 {
3361 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3362 }
3363 else
3364 {
3365 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3366
3367
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3368
3369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3370
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3371 {
3372 12 tempitemx=x;
3373 12 tempitemy=y;
3374 12 }
3375
3376 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3377 }
3378
3379 17 break;
3380
3381 case mfWAND:
3382
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3383 {
3384 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3385 }
3386 else
3387 {
3388 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3389
3390
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3391
3392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3393
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3394 {
3395 28 tempitemx=x;
3396 28 tempitemy=y;
3397 28 }
3398
3399 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3400 }
3401
3402 35 break;
3403
3404 case mfHAMMER:
3405
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3406 {
3407 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3408 }
3409 else
3410 {
3411 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3412
3413
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3414
3415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3416
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3417 {
3418 13 tempitemx=x;
3419 13 tempitemy=y;
3420 13 }
3421
3422 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3423 }
3424
3425 17 break;
3426
3427 case mfARMOS_ITEM:
3428 case mfDIVE_ITEM:
3429
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3430 {
3431 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3432 2064 }
3433 2064 break;
3434
3435 case 16:
3436 case 17:
3437 case 18:
3438 case 19:
3439 case 20:
3440 case 21:
3441 case 22:
3442 case 23:
3443 case 24:
3444 case 25:
3445 case 26:
3446 case 27:
3447 case 28:
3448 case 29:
3449 case 30:
3450 case 31:
3451
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 1800 times.
2808 if(!hints)
3452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1800 times.
3600 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3453 1800 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3454
3455 2808 break;
3456 case mfSECRETSNEXT:
3457 if(!hints)
3458 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3459 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3460
3461 break;
3462
3463 case mfSTRIKE:
3464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3465 {
3466 906 goto special;
3467 }
3468 else
3469 {
3470 break;
3471 }
3472
3473 28392 default: goto special;
3474
3475 special:
3476
8/8
✓ Branch 0 taken 14553 times.
✓ Branch 1 taken 14745 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 14088 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8004 times.
29298 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3477 {
3478
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3479 {
3480 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3481 4913 }
3482 6549 }
3483
3484 29298 break;
3485 }
3486 4559104 }
3487 2279552 }
3488
3489
2/2
✓ Branch 0 taken 6476 times.
✓ Branch 1 taken 6476 times.
12952 if(layer)
3490 {
3491
2/2
✓ Branch 0 taken 6368 times.
✓ Branch 1 taken 108 times.
6476 if(tmpscr->door[0]==dWALK)
3492 108 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3493
3494
2/2
✓ Branch 0 taken 6368 times.
✓ Branch 1 taken 108 times.
6476 if(tmpscr->door[1]==dWALK)
3495 108 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3496
3497
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[2]==dWALK)
3498 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3499
3500
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[3]==dWALK)
3501 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3502
3503
2/2
✓ Branch 0 taken 6452 times.
✓ Branch 1 taken 24 times.
6476 if(tmpscr->door[0]==dBOMB)
3504 {
3505 24 showbombeddoor(dest, 0);
3506 24 }
3507
3508
2/2
✓ Branch 0 taken 6452 times.
✓ Branch 1 taken 24 times.
6476 if(tmpscr->door[1]==dBOMB)
3509 {
3510 24 showbombeddoor(dest, 1);
3511 24 }
3512
3513
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[2]==dBOMB)
3514 {
3515 showbombeddoor(dest, 2);
3516 }
3517
3518
1/2
✓ Branch 0 taken 6476 times.
✗ Branch 1 not taken.
6476 if(tmpscr->door[3]==dBOMB)
3519 {
3520 showbombeddoor(dest, 3);
3521 }
3522 6476 }
3523
3524
2/2
✓ Branch 0 taken 11130 times.
✓ Branch 1 taken 1822 times.
12952 if(tmpscr->stairx + tmpscr->stairy)
3525 {
3526
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 911 times.
1822 if(!hints)
3527 {
3528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 911 times.
911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3529 911 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3530 911 }
3531 else
3532 {
3533
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3534 {
3535 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3536 48 int32_t tempitemx=-16;
3537 48 int32_t tempitemy=-16;
3538
3539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3540
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3541 {
3542 24 tempitemx=tmpscr->stairx;
3543 24 tempitemy=tmpscr->stairy+playing_field_offset;
3544 24 }
3545
3546 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3547 48 }
3548 }
3549 1822 }
3550 }
3551 12952 }
3552
3553 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3554
3555 6307 void draw_lens_over()
3556 {
3557 // Oh, what the heck.
3558 static BITMAP *lens_scr = NULL;
3559 static int32_t last_width = -1;
3560 6307 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3561
3562 // Only redraw the circle if the size has changed
3563
2/2
✓ Branch 0 taken 6303 times.
✓ Branch 1 taken 4 times.
6307 if(width != last_width)
3564 {
3565
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(lens_scr == NULL)
3566 {
3567 4 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3568 4 }
3569
3570 4 clear_to_color(lens_scr, BLACK);
3571 4 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3572 4 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3573 4 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3574 4 last_width=width;
3575 4 }
3576
3577 6307 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3578 6307 }
3579
3580 //----------------------------------------------------------------
3581
3582 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3583 {
3584 //recreating a big bitmap every frame is highly sluggish.
3585
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3586 30701 clear_to_color(wavebuf, BLACK);
3587 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3588
3589 int32_t ofs;
3590 // int32_t amplitude=8;
3591 // int32_t wavelength=4;
3592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3593
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3594 30701 int32_t amp2=168;
3595
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3596 30701 int32_t i=frame%amp2;
3597
3598
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3599 {
3600
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3601 {
3602 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3603 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3604 }
3605 else
3606 {
3607 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3608 }
3609
3610
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3611 {
3612
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3613 {
3614 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3615 1320388608 }
3616 5157768 }
3617 5157768 }
3618 30701 }
3619
3620 576 void draw_fuzzy(int32_t fuzz)
3621 // draws from right half of scrollbuf to framebuf
3622 {
3623 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3624 byte *start, *si, *di;
3625
3626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(fuzz<1)
3627 fuzz = 1;
3628
3629 576 xstep = 128%fuzz;
3630
3631
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 456 times.
576 if(xstep > 0)
3632 456 xstep = fuzz-xstep;
3633
3634 576 ystep = 112%fuzz;
3635
3636
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 408 times.
576 if(ystep > 0)
3637 408 ystep = fuzz-ystep;
3638
3639 576 firsty = 1;
3640
3641
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 20784 times.
21360 for(y=0; y<224;)
3642 {
3643 20784 start = &(scrollbuf->line[y][256]);
3644
3645
4/4
✓ Branch 0 taken 20496 times.
✓ Branch 1 taken 129312 times.
✓ Branch 2 taken 129024 times.
✓ Branch 3 taken 20784 times.
149808 for(dy=0; dy<ystep && dy+y<224; dy++)
3646 {
3647 129024 si = start;
3648 129024 di = &(framebuf->line[y+dy][0]);
3649 129024 i = xstep;
3650 129024 firstx = 1;
3651
3652
2/2
✓ Branch 0 taken 33030144 times.
✓ Branch 1 taken 129024 times.
33159168 for(dx=0; dx<256; dx++)
3653 {
3654 33030144 *(di++) = *si;
3655
3656
2/2
✓ Branch 0 taken 27831552 times.
✓ Branch 1 taken 5198592 times.
33030144 if(++i >= fuzz)
3657 {
3658
2/2
✓ Branch 0 taken 5069568 times.
✓ Branch 1 taken 129024 times.
5198592 if(!firstx)
3659 5069568 si += fuzz;
3660 else
3661 {
3662 129024 si += fuzz-xstep;
3663 129024 firstx = 0;
3664 }
3665
3666 5198592 i = 0;
3667 5198592 }
3668 33030144 }
3669 129024 }
3670
3671
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 576 times.
20784 if(!firsty)
3672 20208 y += fuzz;
3673 else
3674 {
3675 576 y += ystep;
3676 576 ystep = fuzz;
3677 576 firsty = 0;
3678 }
3679 }
3680 576 }
3681
3682 4800661 void updatescr(bool allowwavy)
3683 {
3684
4/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4800633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
4800661 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3685
4/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4800633 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
4800661 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3686
3687
2/2
✓ Branch 0 taken 4774957 times.
✓ Branch 1 taken 25704 times.
4800661 if(toogam)
3688 {
3689 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3690 25704 }
3691
3692
1/2
✓ Branch 0 taken 4800661 times.
✗ Branch 1 not taken.
4800661 if(Showpal)
3693 dump_pal(framebuf);
3694
3695
2/2
✓ Branch 0 taken 4732888 times.
✓ Branch 1 taken 67773 times.
4800661 if(!Playing)
3696 67773 black_opening_count=0;
3697
3698
2/2
✓ Branch 0 taken 4777957 times.
✓ Branch 1 taken 22704 times.
4800661 if(black_opening_count<0) //shape is opening up
3699 {
3700 22704 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3701
3702
2/4
✓ Branch 0 taken 22704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 22704 times.
22704 if(Advance||(!Paused))
3703 {
3704 22704 ++black_opening_count;
3705 22704 }
3706 22704 }
3707
2/2
✓ Branch 0 taken 4768717 times.
✓ Branch 1 taken 9240 times.
4777957 else if(black_opening_count>0) //shape is closing
3708 {
3709 9240 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3710
3711
2/4
✓ Branch 0 taken 9240 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9240 times.
9240 if(Advance||(!Paused))
3712 {
3713 9240 --black_opening_count;
3714 9240 }
3715 9240 }
3716
3717
3/4
✓ Branch 0 taken 4769201 times.
✓ Branch 1 taken 31460 times.
✓ Branch 2 taken 4769201 times.
✗ Branch 3 not taken.
4800661 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3718 {
3719 black_opening_shape = bosCIRCLE;
3720 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3721 refreshTints();
3722 refreshpal=true;
3723 }
3724
3725
2/2
✓ Branch 0 taken 4689478 times.
✓ Branch 1 taken 111183 times.
4800661 if(refreshpal)
3726 {
3727 111183 refreshpal=false;
3728 111183 RAMpal[253] = _RGB(0,0,0);
3729 111183 RAMpal[254] = _RGB(63,63,63);
3730 111183 hw_palette = &RAMpal;
3731 111183 update_hw_pal = true;
3732
3733 111183 create_rgb_table(&rgb_table, RAMpal, NULL);
3734 111183 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3735 111183 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3736
3737
2/2
✓ Branch 0 taken 28462848 times.
✓ Branch 1 taken 111183 times.
28574031 for(int32_t q=0; q<PAL_SIZE; q++)
3738 {
3739 28462848 trans_table2.data[0][q] = q;
3740 28462848 trans_table2.data[q][q] = q;
3741 28462848 }
3742 111183 }
3743
3744 4800661 bool clearwavy = (wavy <= 0);
3745
3746
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 4793416 times.
4800661 if(wavy <= 0)
3747 {
3748 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3749 4793416 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3750 4793416 }
3751
3752 4800661 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3753
3754
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 4769710 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
4800661 if(wavy && Playing && allowwavy)
3755 {
3756 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3757 30701 }
3758
3759
2/2
✓ Branch 0 taken 4793416 times.
✓ Branch 1 taken 7245 times.
4800661 if(clearwavy)
3760 4793416 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3761
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3762 7245 wavy--; // Wavy was set by a script. Decrement it.
3763
3764
5/6
✓ Branch 0 taken 4732888 times.
✓ Branch 1 taken 67773 times.
✓ Branch 2 taken 97913 times.
✓ Branch 3 taken 4634975 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 97913 times.
4800661 if(Playing && msgpos && !screenscrolling)
3765 {
3766
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_bg_display_buf->clip))
3767 97913 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3768
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_portrait_display_buf->clip))
3769 97913 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3770
1/2
✓ Branch 0 taken 97913 times.
✗ Branch 1 not taken.
97913 if(!(msg_txt_display_buf->clip))
3771 97913 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3772 97913 }
3773
3774 /*
3775 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3776 {
3777 BITMAP* subBmp = 0;
3778 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3779 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3780 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3781 destroy_bitmap(subBmp);
3782 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3783 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3784 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3785 }
3786 */
3787
3788
2/2
✓ Branch 0 taken 4779400 times.
✓ Branch 1 taken 21261 times.
4800661 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3789
3790
2/2
✓ Branch 0 taken 4779400 times.
✓ Branch 1 taken 21261 times.
4800661 if(nosubscr)
3791 {
3792 21261 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3793 21261 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3794 21261 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3795 21261 }
3796
3797 //TODO: Optimize blit 'overcalls' -Gleeok
3798
2/2
✓ Branch 0 taken 21261 times.
✓ Branch 1 taken 4779400 times.
4800661 BITMAP *source = nosubscr ? panorama : wavybuf;
3799 4800661 blit(source,framebuf,0,0,0,0,256,224);
3800
3801 4800661 update_hw_screen();
3802 4800661 }
3803
3804 //----------------------------------------------------------------
3805
3806 PALETTE sys_pal;
3807
3808 int32_t onGUISnapshot()
3809 {
3810 char buf[200];
3811 int32_t num=0;
3812 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3813 do
3814 {
3815 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3816 }
3817 while(num<99999 && exists(buf));
3818
3819 BITMAP *b = create_bitmap_ex(8,resx,resy);
3820
3821 if(b)
3822 {
3823 if(MenuOpen)
3824 {
3825 //Cannot load game's palette while GUI elements are in focus. -Z
3826 //If there is a way to do this, then I have missed it.
3827 /*
3828 game_pal();
3829 RAMpal[253] = _RGB(0,0,0);
3830 RAMpal[254] = _RGB(63,63,63);
3831 set_palette_range(RAMpal,0,255,false);
3832 memcpy(RAMpal, snappal, sizeof(snappal));
3833 create_rgb_table(&rgb_table, RAMpal, NULL);
3834 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3835 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3836
3837 for(int32_t q=0; q<PAL_SIZE; q++)
3838 {
3839 trans_table2.data[0][q] = q;
3840 trans_table2.data[q][q] = q;
3841 }
3842 */
3843 //ringcolor(false);
3844 //get_palette(RAMpal);
3845 blit(screen,b,0,0,0,0,resx,resy);
3846 //al_trace("Menu Open\n");
3847 //game_pal();
3848 //PALETTE temppal;
3849 //get_palette(temppal);
3850 //system_pal();
3851 save_bitmap(buf,b,sys_pal);
3852 //save_bitmap(buf,b,RAMpal);
3853 //save_bitmap(buf,b,snappal);
3854 }
3855 else
3856 {
3857 blit(screen,b,0,0,0,0,resx,resy);
3858 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3859 }
3860 destroy_bitmap(b);
3861 }
3862
3863 return D_O_K;
3864 }
3865
3866 int32_t onNonGUISnapshot()
3867 {
3868 PALETTE temppal;
3869 get_palette(temppal);
3870 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3871
3872 char buf[200];
3873 int32_t num=0;
3874
3875 do
3876 {
3877 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3878 }
3879 while(num<99999 && exists(buf));
3880
3881 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3882
3883 return D_O_K;
3884 }
3885
3886 int32_t onSnapshot()
3887 {
3888 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3889 {
3890 onGUISnapshot();
3891 }
3892 else
3893 {
3894 onNonGUISnapshot();
3895 }
3896
3897 return D_O_K;
3898 }
3899
3900 int32_t onSaveMapPic()
3901 {
3902 int32_t mapres2 = 0;
3903 char buf[200];
3904 int32_t num=0;
3905 mapscr tmpscr_b[2];
3906 mapscr tmpscr_c[6];
3907 BITMAP* _screen_draw_buffer = NULL;
3908 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3909 set_clip_state(_screen_draw_buffer,1);
3910
3911 for(int32_t i=0; i<6; ++i)
3912 {
3913 tmpscr_c[i] = tmpscr2[i];
3914 tmpscr2[i].zero_memory();
3915
3916 if(i>=2)
3917 {
3918 continue;
3919 }
3920
3921 tmpscr_b[i] = tmpscr[i];
3922 tmpscr[i].zero_memory();
3923 }
3924
3925 do
3926 {
3927 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3928 }
3929 while(num<99999 && exists(buf));
3930
3931 BITMAP* mappic = NULL;
3932
3933
3934 bool done=false, redraw=true;
3935
3936 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3937
3938 if(!mappic)
3939 {
3940 system_pal();
3941 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3942 game_pal();
3943 return D_O_K;;
3944 }
3945
3946 // draw the map
3947 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3948
3949 for(int32_t y=0; y<8; y++)
3950 {
3951 for(int32_t x=0; x<16; x++)
3952 {
3953 if(!displayOnMap(x, y))
3954 {
3955 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3956 }
3957 else
3958 {
3959 int32_t s = (y<<4) + x;
3960 loadscr2(1,s,-1);
3961
3962 for(int32_t i=0; i<6; i++)
3963 {
3964 if(tmpscr[1].layermap[i]<=0)
3965 continue;
3966
3967 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
3968 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
3969 {
3970 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
3971
3972 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
3973 }
3974 }
3975
3976 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3977
3978 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3979
3980 putscr(_screen_draw_buffer,256,0,tmpscr+1);
3981 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
3982
3983 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
3984
3985 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
3986 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
3987 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
3988 {
3989 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
3990 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
3991 }
3992 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
3993
3994 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
3995
3996 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
3997 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
3998 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
3999 {
4000 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4001 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4002 }
4003 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4004 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4005
4006 }
4007
4008 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4009 }
4010 }
4011
4012 for(int32_t i=0; i<6; ++i)
4013 {
4014 tmpscr2[i]=tmpscr_c[i];
4015
4016 if(i>=2)
4017 {
4018 continue;
4019 }
4020
4021 tmpscr[i]=tmpscr_b[i];
4022 }
4023
4024 save_bitmap(buf,mappic,RAMpal);
4025 destroy_bitmap(mappic);
4026 destroy_bitmap(_screen_draw_buffer);
4027 return D_O_K;
4028 }
4029
4030 /*
4031 int32_t onSaveMapPic()
4032 {
4033 BITMAP* mappic = NULL;
4034 BITMAP* _screen_draw_buffer = NULL;
4035 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4036 int32_t mapres2 = 0;
4037 char buf[20];
4038 int32_t num=0;
4039 set_clip_state(_screen_draw_buffer,1);
4040 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4041
4042 do
4043 {
4044 sprintf(buf, "zelda%03d.png", ++num);
4045 }
4046 while(num<999 && exists(buf));
4047
4048 // if(!mappic) {
4049 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4050
4051 if(!mappic)
4052 {
4053 system_pal();
4054 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4055 game_pal();
4056 return D_O_K;
4057 }
4058
4059 // }
4060
4061 int32_t layermap, layerscreen;
4062 int32_t x2=0;
4063
4064 // draw the map
4065 for(int32_t y=0; y<8; y++)
4066 {
4067 for(int32_t x=0; x<16; x++)
4068 {
4069 int32_t s = (y<<4) + x;
4070
4071 if(!displayOnMap(x, y))
4072 {
4073 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4074 }
4075 else
4076 {
4077 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4078 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4079
4080 for(int32_t k=0; k<4; k++)
4081 {
4082 if(k==2)
4083 {
4084 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4085 }
4086
4087 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4088
4089 if(layermap>-1)
4090 {
4091 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4092
4093 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4094 {
4095 for(int32_t i=0; i<176; i++)
4096 {
4097 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4098 }
4099 }
4100 else
4101 {
4102 for(int32_t i=0; i<176; i++)
4103 {
4104 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4105 }
4106 }
4107 }
4108 }
4109
4110 for(int32_t i=0; i<176; i++)
4111 {
4112 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4113 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4114 {
4115 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4116 }
4117 }
4118
4119 for(int32_t k=4; k<6; k++)
4120 {
4121 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4122
4123 if(layermap>-1)
4124 {
4125 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4126
4127 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4128 {
4129 for(int32_t i=0; i<176; i++)
4130 {
4131 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4132 }
4133 }
4134 else
4135 {
4136 for(int32_t i=0; i<176; i++)
4137 {
4138 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4139 }
4140 }
4141 }
4142 }
4143 }
4144
4145 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4146 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4147 }
4148
4149 }
4150
4151 save_bitmap(buf,mappic,RAMpal);
4152 destroy_bitmap(mappic);
4153 destroy_bitmap(_screen_draw_buffer);
4154 return D_O_K;
4155 }
4156 */
4157
4158 14 void f_Quit(int32_t type)
4159 {
4160
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4161 return;
4162
4163 14 bool from_menu = is_sys_pal;
4164
4165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4166 {
4167 14 music_pause();
4168 14 pause_all_sfx();
4169 14 }
4170 14 enter_sys_pal();
4171 14 clear_keybuf();
4172
4173
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4174 14 replay_poll();
4175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4176 14 replay_peek_quit();
4177
4178
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4179 switch(type)
4180 {
4181 case qQUIT:
4182 onQuit();
4183 break;
4184
4185 case qRESET:
4186 onReset();
4187 break;
4188
4189 case qEXIT:
4190 onExit();
4191 break;
4192 }
4193
4194
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4195 {
4196 14 kill_sfx();
4197 14 music_stop();
4198 14 exit_sys_pal();
4199 14 update_hw_screen();
4200 14 }
4201 else
4202 {
4203 exit_sys_pal();
4204 if(!from_menu)
4205 {
4206 music_resume();
4207 resume_all_sfx();
4208 }
4209 }
4210
4211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4212 14 show_mouse(NULL);
4213 14 eat_buttons();
4214
4215 14 zc_readrawkey(KEY_ESC);
4216
4217 14 zc_readrawkey(KEY_ENTER);
4218 14 }
4219
4220 //----------------------------------------------------------------
4221
4222 int32_t onNoWalls()
4223 {
4224 cheats_enqueue(Cheat::Walls);
4225 return D_O_K;
4226 }
4227
4228 int32_t onIgnoreSideview()
4229 {
4230 cheats_enqueue(Cheat::IgnoreSideView);
4231 return D_O_K;
4232 }
4233
4234 4800616 int32_t input_idle(bool checkmouse)
4235 {
4236 static int32_t mx, my, mz, mb;
4237
4238
4/6
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110232 times.
✓ Branch 3 taken 3690384 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1110232 times.
5910848 if(keypressed() || zc_key_pressed() ||
4239
4/8
✓ Branch 0 taken 1110232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1110232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1110232 times.
✗ Branch 7 not taken.
1110232 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4240 {
4241 3690384 idle_count = 0;
4242
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3690384 times.
3690384 if(active_count < MAX_ACTIVE)
4244 {
4245 3690384 ++active_count;
4246 3690384 }
4247 3690384 }
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1110232 times.
1110232 else if(idle_count < MAX_IDLE)
4249 {
4250 1110232 ++idle_count;
4251 1110232 active_count = 0;
4252 1110232 }
4253
4254 4800616 mx = mouse_x;
4255 4800616 my = mouse_y;
4256 4800616 mz = mouse_z;
4257 4800616 mb = mouse_b;
4258
4259 4800616 return idle_count;
4260 }
4261
4262 int32_t onGoFast()
4263 {
4264 cheats_enqueue(Cheat::Fast);
4265 return D_O_K;
4266 }
4267
4268 int32_t onKillCheat()
4269 {
4270 cheats_enqueue(Cheat::Kill);
4271 return D_O_K;
4272 }
4273
4274 int32_t onShowLayer0()
4275 {
4276 show_layer_0 = !show_layer_0;
4277 return D_O_K;
4278 }
4279 int32_t onShowLayer1()
4280 {
4281 show_layer_1 = !show_layer_1;
4282 return D_O_K;
4283 }
4284 int32_t onShowLayer2()
4285 {
4286 show_layer_2 = !show_layer_2;
4287 return D_O_K;
4288 }
4289 int32_t onShowLayer3()
4290 {
4291 show_layer_3 = !show_layer_3;
4292 return D_O_K;
4293 }
4294 int32_t onShowLayer4()
4295 {
4296 show_layer_4 = !show_layer_4;
4297 return D_O_K;
4298 }
4299 int32_t onShowLayer5()
4300 {
4301 show_layer_5 = !show_layer_5;
4302 return D_O_K;
4303 }
4304 int32_t onShowLayer6()
4305 {
4306 show_layer_6 = !show_layer_6;
4307 return D_O_K;
4308 }
4309 int32_t onShowLayerO()
4310 {
4311 show_layer_over=!show_layer_over;
4312 return D_O_K;
4313 }
4314 int32_t onShowLayerP()
4315 {
4316 show_layer_push=!show_layer_push;
4317 return D_O_K;
4318 }
4319 int32_t onShowLayerS()
4320 {
4321 show_sprites=!show_sprites;
4322 return D_O_K;
4323 }
4324 int32_t onShowLayerF()
4325 {
4326 show_ffcs=!show_ffcs;
4327 return D_O_K;
4328 }
4329 int32_t onShowLayerW()
4330 {
4331 show_walkflags=!show_walkflags;
4332 return D_O_K;
4333 }
4334 int32_t onShowLayerE()
4335 {
4336 show_effectflags=!show_effectflags;
4337 return D_O_K;
4338 }
4339 int32_t onShowFFScripts()
4340 {
4341 show_ff_scripts=!show_ff_scripts;
4342 return D_O_K;
4343 }
4344 int32_t onShowHitboxes()
4345 {
4346 show_hitboxes=!show_hitboxes;
4347 return D_O_K;
4348 }
4349
4350 int32_t onLightSwitch()
4351 {
4352 cheats_enqueue(Cheat::Light);
4353 return D_O_K;
4354 }
4355
4356 int32_t onGoTo();
4357 int32_t onGoToComplete();
4358
4359 4800616 void syskeys()
4360 {
4361 4800616 update_system_keys();
4362
4363 int32_t oldtitle_version;
4364
4365
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(close_button_quit)
4366 {
4367 close_button_quit=false;
4368 f_Quit(qEXIT);
4369 }
4370
4371 4800616 poll_joystick();
4372
4373
2/10
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4800616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4800616 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4374 {
4375 oldtitle_version=title_version;
4376 System();
4377 }
4378
4379 4800616 mouse_down=gui_mouse_b();
4380
4381
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F1))
4382 {
4383 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4384 {
4385 halt=!halt;
4386 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4387 }
4388 else
4389 {
4390 Throttlefps=!Throttlefps;
4391 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4392 logic_counter=0;
4393 }
4394 }
4395
4396 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4397 /*
4398 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4399 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4400 */
4401
4402
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F2))
4403 {
4404 ShowFPS=!ShowFPS;
4405 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4406 }
4407
4408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4409
4410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(zc_read_system_key(KEY_F4) && Playing)
4411 {
4412 Paused=true;
4413 Advance=true;
4414 }
4415
4416
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F6)) onTryQuit();
4417
4418 #ifndef ALLEGRO_MACOSX
4419
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4420
4421
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4422 #else
4423 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4424
4425 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4426 #endif
4427
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4800616 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4428
4429
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if (zc_read_system_key(KEY_F12))
4430 {
4431 onSnapshot();
4432 }
4433
4434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4800616 if(debug_enabled && zc_read_system_key(KEY_TAB))
4435 set_debug(!get_debug());
4436
4437
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=1)
4438 {
4439
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4440 {
4441 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4442
4443 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4444
4445 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4446
4447 if(zc_readkey(KEY_B))
4448 {
4449 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4450 }
4451
4452 if(zc_readkey(KEY_A))
4453 {
4454 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4455 }
4456 }
4457 20470 }
4458
4459
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=2)
4460 {
4461
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4462 {
4463 if(rI())
4464 {
4465 cheats_enqueue(Cheat::Clock);
4466 }
4467 }
4468 20470 }
4469
4470
3/4
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20470 times.
✓ Branch 3 taken 4780146 times.
4800616 if(get_debug() || cheat>=4)
4471 {
4472
1/2
✓ Branch 0 taken 20470 times.
✗ Branch 1 not taken.
20470 if( CheatModifierKeys() )
4473 {
4474 if(rF11())
4475 {
4476 cheats_enqueue(Cheat::Walls);
4477 }
4478
4479 if(rQ())
4480 {
4481 cheats_enqueue(Cheat::Fast);
4482 }
4483
4484 if(zc_readkey(KEY_F))
4485 {
4486 cheats_enqueue(Cheat::Freeze);
4487 }
4488
4489 if(zc_readkey(KEY_G)) onGoToComplete();
4490
4491 if(zc_readkey(KEY_0)) onShowLayer0();
4492
4493 if(zc_readkey(KEY_1)) onShowLayer1();
4494
4495 if(zc_readkey(KEY_2)) onShowLayer2();
4496
4497 if(zc_readkey(KEY_3)) onShowLayer3();
4498
4499 if(zc_readkey(KEY_4)) onShowLayer4();
4500
4501 if(zc_readkey(KEY_5)) onShowLayer5();
4502
4503 if(zc_readkey(KEY_6)) onShowLayer6();
4504
4505 //if(zc_readkey(KEY_7)) onShowLayerO();
4506 if(zc_readkey(KEY_7)) onShowLayerF();
4507
4508 if(zc_readkey(KEY_8)) onShowLayerS();
4509
4510 if(zc_readkey(KEY_W)) onShowLayerW();
4511
4512 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4513
4514 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4515
4516 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4517 if(zc_readkey(KEY_O)) onShowLayerO();
4518 if(zc_readkey(KEY_P)) onShowLayerP();
4519 if(zc_readkey(KEY_C)) onShowHitboxes();
4520 if(zc_readkey(KEY_F)) onShowFFScripts();
4521 }
4522 20470 }
4523
4524
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(volkeys)
4525 {
4526 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4527
4528 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4529
4530 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4531
4532 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4533 }
4534
4535
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4800616 if(!get_debug() || !SystemKeys || replay_is_replaying())
4536 4800616 goto bottom;
4537
4538 if(zc_readkey(KEY_D))
4539 {
4540 details = !details;
4541 rectfill(screen,0,0,319,7,BLACK);
4542 rectfill(screen,0,8,31,239,BLACK);
4543 rectfill(screen,288,8,319,239,BLACK);
4544 rectfill(screen,32,232,287,239,BLACK);
4545 }
4546
4547 if(zc_readkey(KEY_P)) Paused=!Paused;
4548
4549 //if(zc_readkey(KEY_P)) centerHero();
4550 if(zc_readkey(KEY_A))
4551 {
4552 Paused=true;
4553 Advance=true;
4554 }
4555
4556 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4557 #ifndef ALLEGRO_MACOSX
4558 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4559
4560 if(zc_readkey(KEY_F7))
4561 {
4562 Matrix(ss_speed, ss_density, 0);
4563 game_pal();
4564 }
4565 #else
4566 // The reason these are different on Mac in the first place is that
4567 // the OS doesn't let us use F9 and F10...
4568 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4569
4570 if(zc_readkey(KEY_F9))
4571 {
4572 Matrix(ss_speed, ss_density, 0);
4573 game_pal();
4574 }
4575 #endif
4576 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4577 {
4578 //change containers
4579 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4580 {
4581 //magic containers
4582 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4583 {
4584 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4585 }
4586 else
4587 {
4588 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4589 }
4590 }
4591 else
4592 {
4593 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4594 {
4595 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4596 }
4597 else
4598 {
4599 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4600 }
4601 }
4602 }
4603
4604 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4605 {
4606 //change containers
4607 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4608 {
4609 //magic containers
4610 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4611 {
4612 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4613 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4614 //heart containers
4615 }
4616 else
4617 {
4618 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4619 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4620 }
4621 }
4622 else
4623 {
4624 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4625 {
4626 game->set_magic(zc_max(game->get_magic()-1,0));
4627 }
4628 else
4629 {
4630 game->set_life(zc_max(game->get_life()-1,0));
4631 }
4632 }
4633 }
4634
4635 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4636
4637 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4638
4639 verifyBothWeapons();
4640
4641 bottom:
4642
4643
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(input_idle(true) > after_time())
4644 {
4645 Matrix(ss_speed, ss_density, 0);
4646 game_pal();
4647 }
4648 4800616 }
4649
4650 330136 void checkQuitKeys()
4651 {
4652 #ifndef ALLEGRO_MACOSX
4653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4654
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4656 #else
4657 if(key[KEY_F7]) f_Quit(qRESET);
4658
4659 if(key[KEY_F8]) f_Quit(qEXIT);
4660 #endif
4661 330136 }
4662
4663 61410 bool CheatModifierKeys()
4664 {
4665 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4666 // to trigger cheats.
4667
1/2
✓ Branch 0 taken 61410 times.
✗ Branch 1 not taken.
61410 if (replay_is_replaying())
4668 61410 return false;
4669
4670 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4671 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4672 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4673 {
4674 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4675 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4676 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4677 {
4678 return true;
4679 }
4680 }
4681 return false;
4682 61410 }
4683
4684 //99:05:54, for some reason?
4685 #define OLDMAXTIME 21405240
4686 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4687 #define MAXTIME 1944000000
4688
4689 4800661 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4690 {
4691
2/2
✓ Branch 0 taken 4539250 times.
✓ Branch 1 taken 261411 times.
4800661 if(zcmusic!=NULL)
4692 {
4693 261411 zcmusic_poll();
4694 261411 }
4695
4696 4800661 updatescr(allowwavy);
4697
4698
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4800661 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4800661 times.
4800661 while(Paused && !Advance && !Quit)
4699 {
4700 // have to call this, otherwise we'll get an infinite loop
4701 syskeys();
4702 if(allowF6Script)
4703 {
4704 FFCore.runF6Engine();
4705 }
4706 throttleFPS();
4707
4708 #ifdef _WIN32
4709
4710 if(use_dwm_flush)
4711 {
4712 do_DwmFlush();
4713 }
4714
4715 #endif
4716
4717 // to keep music playing
4718 if(zcmusic!=NULL)
4719 {
4720 zcmusic_poll();
4721 }
4722
4723 update_hw_screen();
4724 }
4725
4726
2/2
✓ Branch 0 taken 4800625 times.
✓ Branch 1 taken 36 times.
4800661 if(Quit)
4727 36 return;
4728
4729
3/4
✓ Branch 0 taken 4732881 times.
✓ Branch 1 taken 67744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4732881 times.
4800625 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4730 4732881 game->change_time(1);
4731
4732 4800625 Advance=false;
4733
4734
2/4
✓ Branch 0 taken 4800625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4800625 times.
4800625 if (!replay_is_active() || replay_get_version() >= 11)
4735 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4736 down_control_states[i] = raw_control_state[i];
4737
4738
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_active())
4739 {
4740
2/2
✓ Branch 0 taken 1270454 times.
✓ Branch 1 taken 3530162 times.
4800616 if (replay_get_version() >= 3)
4741 3530162 replay_poll();
4742
4743
5/6
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1379964 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 1279429 times.
4800616 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4744 100535 replay_peek_input();
4745 4800616 }
4746
4747 4800625 load_control_called_this_frame = false;
4748
4749 4800625 poll_keyboard();
4750 4800625 update_keys();
4751
4752 4800625 ++frame;
4753
4754
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_replaying())
4755 4800616 replay_do_cheats();
4756 4800625 syskeys();
4757
4758 // The mouse variables can change from the mouse thread at anytime during a frame,
4759 // so save the result at the start so that replaying is consistent.
4760 4800625 script_mouse_x = gui_mouse_x();
4761 4800625 script_mouse_y = gui_mouse_y();
4762 4800625 script_mouse_z = mouse_z;
4763 4800625 script_mouse_b = mouse_b;
4764
4765 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4766 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4767 // approach here means it doesn't matter which call adds the cheat.
4768 4800625 cheats_execute_queued();
4769
4770
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 4800616 times.
4800625 if (replay_is_replaying())
4771 4800616 replay_peek_quit();
4772
2/2
✓ Branch 0 taken 4800611 times.
✓ Branch 1 taken 14 times.
4800625 if (GameFlags & GAMEFLAG_TRYQUIT)
4773 14 replay_step_quit(0);
4774
2/2
✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 4799156 times.
4800625 if(allowF6Script)
4775 {
4776 4799156 FFCore.runF6Engine();
4777 4799156 }
4778
2/2
✓ Branch 0 taken 4800484 times.
✓ Branch 1 taken 141 times.
4800625 if (Quit)
4779 141 replay_step_quit(Quit);
4780 // Someday... maybe install a Turbo button here?
4781 4800625 throttleFPS();
4782
4783 #ifdef _WIN32
4784
4785 if(use_dwm_flush)
4786 {
4787 do_DwmFlush();
4788 }
4789
4790 #endif
4791
4792 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4793
2/2
✓ Branch 0 taken 6449 times.
✓ Branch 1 taken 4794176 times.
4800625 if(sfxcleanup)
4794 4794176 sfx_cleanup();
4795 4800661 }
4796
4797 12 void zapout()
4798 {
4799 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4800 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4801
4802 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4803 12 script_drawing_commands.Clear();
4804
4805 // zap out
4806
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=1; i<=24; i++)
4807 {
4808 288 draw_fuzzy(i);
4809 288 advanceframe(true);
4810
4811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4812 {
4813 break;
4814 }
4815 288 }
4816 12 }
4817
4818 12 void zapin()
4819 {
4820 12 FFCore.warpScriptCheck();
4821 12 draw_screen(tmpscr);
4822 12 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4823 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4824 12 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4825
4826 // zap out
4827 12 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4828
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 288 times.
300 for(int32_t i=24; i>=1; i--)
4829 {
4830 288 draw_fuzzy(i);
4831 288 advanceframe(true);
4832
4833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(Quit)
4834 {
4835 break;
4836 }
4837 288 }
4838 12 }
4839
4840
4841 23 void wavyout(bool showhero)
4842 {
4843 23 draw_screen(tmpscr, showhero);
4844 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4845
4846 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4847 23 clear_to_color(wavebuf,0);
4848 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4849
4850 static PALETTE wavepal;
4851
4852 int32_t ofs;
4853 23 int32_t amplitude=8;
4854
4855 23 int32_t wavelength=4;
4856 23 double palpos=0, palstep=4, palstop=126;
4857
4858 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4859
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4860 {
4861
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4862 {
4863 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4864 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4865 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4866 247296 }
4867
4868 966 palpos+=palstep;
4869
4870
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4871 {
4872 966 hw_palette = &wavepal;
4873 966 update_hw_pal = true;
4874 966 }
4875 else
4876 {
4877 hw_palette = &RAMpal;
4878 update_hw_pal = true;
4879 }
4880
4881
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4882 {
4883
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4884 {
4885 41545728 ofs=0;
4886
4887
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4888 {
4889 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4890 10139136 }
4891
4892 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4893 41545728 }
4894 162288 }
4895
4896 966 advanceframe(true);
4897
4898 // animate_combos();
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4900 break;
4901 966 }
4902
4903 23 destroy_bitmap(wavebuf);
4904 23 }
4905
4906 23 void wavyin()
4907 {
4908 23 draw_screen(tmpscr);
4909 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4910
4911 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4912 23 clear_to_color(wavebuf,0);
4913 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4914
4915 static PALETTE wavepal;
4916
4917 //Breaks dark rooms.
4918 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4919 /*
4920 loadfullpal();
4921 loadlvlpal(DMaps[currdmap].color);
4922 ringcolor(false);
4923 */
4924 23 refreshpal=false;
4925 int32_t ofs;
4926 23 int32_t amplitude=8;
4927 23 int32_t wavelength=4;
4928 23 double palpos=168, palstep=4, palstop=126;
4929
4930 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4931
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4932 {
4933
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4934 {
4935 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4936 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4937 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4938 247296 }
4939
4940 966 palpos-=palstep;
4941
4942
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4943 {
4944 966 hw_palette = &wavepal;
4945 966 update_hw_pal = true;
4946 966 }
4947 else
4948 {
4949 hw_palette = &RAMpal;
4950 update_hw_pal = true;
4951 }
4952
4953
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4954 {
4955
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4956 {
4957 41545728 ofs=0;
4958
4959
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4960 {
4961 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4962 10386432 }
4963
4964 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4965 41545728 }
4966 162288 }
4967
4968 966 advanceframe(true);
4969 // animate_combos();
4970
4971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4972 break;
4973 966 }
4974
4975 23 destroy_bitmap(wavebuf);
4976 23 }
4977
4978 1252 void blackscr(int32_t fcnt,bool showsubscr)
4979 {
4980 1252 reset_pal_cycling();
4981 1252 script_drawing_commands.Clear();
4982
4983 1252 FFCore.warpScriptCheck();
4984 1252 bool showtime = game->should_show_time();
4985
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 37490 times.
38742 while(fcnt>0)
4986 {
4987 37490 clear_bitmap(framebuf);
4988
4989
2/2
✓ Branch 0 taken 9360 times.
✓ Branch 1 taken 28130 times.
37490 if(showsubscr)
4990 {
4991 28130 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
4992
3/4
✓ Branch 0 taken 28130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 27380 times.
28130 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4993 {
4994 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4995 750 }
4996 28130 }
4997
4998 37490 advanceframe(true);
4999
5000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37490 times.
37490 if(Quit)
5001 break;
5002
5003 37490 --fcnt;
5004 }
5005 1252 }
5006
5007 332 void openscreen(int32_t shape)
5008 {
5009 332 reset_pal_cycling();
5010 332 black_opening_count=0;
5011
5012
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
332 if(COOLSCROLL || shape>-1)
5013 {
5014 234 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5015 234 return;
5016 }
5017 else
5018 {
5019 98 Hero.setDontDraw(true);
5020 98 show_subscreen_dmap_dots=false;
5021 98 show_subscreen_numbers=false;
5022 // show_subscreen_items=false;
5023 98 show_subscreen_life=false;
5024 }
5025
5026 98 int32_t x=128;
5027
5028 98 FFCore.warpScriptCheck();
5029
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5030 {
5031 7840 draw_screen(tmpscr);
5032 //? draw_screen already draws the subscreen -DD
5033 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5034 7840 x=128-(((i*128/80)/8)*8);
5035
5036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5037 {
5038 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5039 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5040 7840 }
5041
5042 7840 advanceframe(true);
5043
5044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5045 {
5046 break;
5047 }
5048 7840 }
5049
5050 98 Hero.setDontDraw(false);
5051 98 show_subscreen_items=true;
5052 98 show_subscreen_dmap_dots=true;
5053 332 }
5054
5055 void closescreen(int32_t shape)
5056 {
5057 reset_pal_cycling();
5058 black_opening_count=0;
5059
5060 if(COOLSCROLL || shape>-1)
5061 {
5062 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5063 return;
5064 }
5065 else
5066 {
5067 Hero.setDontDraw(true);
5068 show_subscreen_dmap_dots=false;
5069 show_subscreen_numbers=false;
5070 // show_subscreen_items=false;
5071 show_subscreen_life=false;
5072 }
5073
5074 int32_t x=128;
5075
5076 FFCore.warpScriptCheck();
5077 for(int32_t i=79; i>=0; --i)
5078 {
5079 draw_screen(tmpscr);
5080 //? draw_screen already draws the subscreen -DD
5081 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5082 x=128-(((i*128/80)/8)*8);
5083
5084 if(x>0)
5085 {
5086 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5087 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5088 }
5089
5090 advanceframe(true);
5091
5092 if(Quit)
5093 {
5094 break;
5095 }
5096 }
5097
5098 Hero.setDontDraw(false);
5099 show_subscreen_items=true;
5100 show_subscreen_dmap_dots=true;
5101 }
5102
5103 84 int32_t TriforceCount()
5104 {
5105 84 int32_t c=0;
5106
5107
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
756 for(int32_t i=1; i<=8; i++)
5108
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 374 times.
1046 if(game->lvlitems[i]&liTRIFORCE)
5109 374 ++c;
5110
5111 84 return c;
5112 }
5113
5114 int32_t onCustomGame()
5115 {
5116 int32_t file = getsaveslot();
5117
5118 if(file < 0)
5119 return D_O_K;
5120
5121 bool ret = (custom_game(file)!=0);
5122 return ret ? D_CLOSE : D_O_K;
5123 }
5124
5125 int32_t onContinue()
5126 {
5127 return D_CLOSE;
5128 }
5129
5130 int32_t onEsc() // Unused?? -L
5131 {
5132 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5133 }
5134
5135 int32_t onVsync()
5136 {
5137 Throttlefps = !Throttlefps;
5138 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5139 return D_O_K;
5140 }
5141
5142 int32_t onWinPosSave()
5143 {
5144 SaveWinPos = !SaveWinPos;
5145 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5146 return D_O_K;
5147 }
5148
5149 int32_t onClickToFreeze()
5150 {
5151 ClickToFreeze = !ClickToFreeze;
5152 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5153 return D_O_K;
5154 }
5155
5156 int32_t OnSaveZCConfig()
5157 {
5158 if(jwin_alert3(
5159 "Save Configuration",
5160 "Are you sure that you wish to save your present configuration settings?",
5161 "This will overwrite your prior settings!",
5162 NULL,
5163 "&Yes",
5164 "&No",
5165 NULL,
5166 'y',
5167 'n',
5168 0,
5169 lfont) == 1)
5170 {
5171 save_game_configs();
5172 return D_O_K;
5173 }
5174 else return D_O_K;
5175 }
5176
5177 int32_t OnnClearQuestDir()
5178 {
5179 if(jwin_alert3(
5180 "Clear Current Directory Cache",
5181 "Are you sure that you wish to clear the current cached directory?",
5182 "This will default the current directory to the ROOT for this instance of ZC Player!",
5183 NULL,
5184 "&Yes",
5185 "&No",
5186 NULL,
5187 'y',
5188 'n',
5189 0,
5190 lfont) == 1)
5191 {
5192 zc_set_config("zeldadx","win_qst_dir","");
5193 flush_config_file();
5194 strcpy(qstdir,"");
5195 #ifdef __EMSCRIPTEN__
5196 em_sync_fs();
5197 #endif
5198 return D_O_K;
5199 }
5200 else return D_O_K;
5201 }
5202
5203
5204 int32_t onConsoleZASM()
5205 {
5206 if ( !zasm_debugger )
5207 {
5208 AlertDialog("WARNING: ZASM Debugger",
5209 "Enabling this will open the ZASM Debugger Console"
5210 "\nThis will likely grind ZC to a halt with lag."
5211 "\nTo make any use of this, it is suggested that you read"
5212 "\nthe documentation for 'void Breakpoint(char[] string);'"
5213 " in 'ZScript_Additions.txt'"
5214 "\nThis is not recommended for normal users,"
5215 " and is only intended for ZC developers,"
5216 "\nor quest developers coding directly in ZASM"
5217 "\nAre you sure that you wish to open the ZASM Debugger?",
5218 [&](bool ret,bool)
5219 {
5220 if(ret)
5221 {
5222 FFCore.ZASMPrint(true);
5223 }
5224 }).show();
5225 return D_O_K;
5226 }
5227 else
5228 {
5229 FFCore.ZASMPrint(false);
5230 return D_O_K;
5231 }
5232 }
5233
5234
5235 int32_t onConsoleZScript()
5236 {
5237 if ( !zscript_debugger )
5238 {
5239 AlertDialog("ZScript Debugger",
5240 "Enabling this will open the ZScript Debugger Console"
5241 "\nThis will display any messages logged by scripts,"
5242 " including script errors."
5243 "\nAre you sure that you wish to open the ZScript Debugger?",
5244 [&](bool ret,bool)
5245 {
5246 if(ret)
5247 {
5248 FFCore.ZScriptConsole(true);
5249 }
5250 }).show();
5251 return D_O_K;
5252 }
5253 else
5254 {
5255 FFCore.ZScriptConsole(false);
5256 return D_O_K;
5257 }
5258 }
5259
5260 int32_t onClrConsoleOnLoad()
5261 {
5262 clearConsoleOnLoad = !clearConsoleOnLoad;
5263 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5264 return D_O_K;
5265 }
5266
5267
5268 int32_t onFrameSkip()
5269 {
5270 FrameSkip = !FrameSkip;
5271 return D_O_K;
5272 }
5273
5274 int32_t onSaveDragResize()
5275 {
5276 SaveDragResize = !SaveDragResize;
5277 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5278 return D_O_K;
5279 }
5280
5281 int32_t onDragAspect()
5282 {
5283 DragAspect = !DragAspect;
5284 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5285 return D_O_K;
5286 }
5287
5288 int32_t onTransLayers()
5289 {
5290 TransLayers = !TransLayers;
5291 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5292 return D_O_K;
5293 }
5294
5295 int32_t onNESquit()
5296 {
5297 NESquit = !NESquit;
5298 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5299 return D_O_K;
5300 }
5301
5302 int32_t onVolKeys()
5303 {
5304 volkeys = !volkeys;
5305 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5306 return D_O_K;
5307 }
5308
5309 int32_t onShowFPS()
5310 {
5311 ShowFPS = !ShowFPS;
5312 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5313 return D_O_K;
5314 }
5315
5316 566472688 bool is_Fkey(int32_t k)
5317 {
5318
2/2
✓ Branch 0 taken 57607392 times.
✓ Branch 1 taken 508865296 times.
566472688 switch(k)
5319 {
5320 case KEY_F1:
5321 case KEY_F2:
5322 case KEY_F3:
5323 case KEY_F4:
5324 case KEY_F5:
5325 case KEY_F6:
5326 case KEY_F7:
5327 case KEY_F8:
5328 case KEY_F9:
5329 case KEY_F10:
5330 case KEY_F11:
5331 case KEY_F12:
5332 57607392 return true;
5333 }
5334
5335 508865296 return false;
5336 566472688 }
5337
5338 void kb_getkey(DIALOG *d)
5339 {
5340 d->flags|=D_SELECTED;
5341
5342 scare_mouse();
5343 jwin_button_proc(MSG_DRAW,d,0);
5344 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5345 // text_mode(vc(11));
5346 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5347 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5348 unscare_mouse();
5349
5350 update_hw_screen(true);
5351
5352 clear_keybuf();
5353 int32_t k = next_press_key();
5354 clear_keybuf();
5355
5356 //shnarf
5357 //47=f1
5358 //59=esc
5359 if(k>0 && k<123 && !((k>46)&&(k<60)))
5360 *((int32_t*)d->dp3) = k;
5361
5362
5363 d->flags&=~D_SELECTED;
5364 }
5365
5366
5367 //Used by all keyboard key settings dialogues.
5368 void kb_clearjoystick(DIALOG *d)
5369 {
5370 d->flags|=D_SELECTED;
5371
5372 scare_mouse();
5373 jwin_button_proc(MSG_DRAW,d,0);
5374 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5375 // text_mode(vc(11));
5376 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5377 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5378 unscare_mouse();
5379
5380 update_hw_screen(true);
5381
5382 clear_keybuf();
5383 int32_t k = next_press_key();
5384 clear_keybuf();
5385
5386 //shnarf
5387 //47=f1
5388 //59=esc
5389 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5390 // *((int32_t*)d->dp3) = k;
5391 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5392
5393
5394 d->flags&=~D_SELECTED;
5395 }
5396
5397 //Clears key to 0.
5398 //Used by all keyboard key settings dialogues.
5399 void kb_clearkey(DIALOG *d)
5400 {
5401 d->flags|=D_SELECTED;
5402
5403 scare_mouse();
5404 jwin_button_proc(MSG_DRAW,d,0);
5405 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5406 // text_mode(vc(11));
5407 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5408 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5409 unscare_mouse();
5410
5411 update_hw_screen(true);
5412
5413 clear_keybuf();
5414 int32_t k = next_press_key();
5415 clear_keybuf();
5416
5417 //shnarf
5418 //47=f1
5419 //59=esc
5420 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5421 // *((int32_t*)d->dp3) = k;
5422 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5423
5424
5425 d->flags&=~D_SELECTED;
5426 }
5427
5428
5429 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5430 {
5431 switch(msg)
5432 {
5433 case MSG_KEY:
5434 case MSG_CLICK:
5435
5436 kb_clearjoystick(d);
5437
5438 while(gui_mouse_b())
5439 {
5440 clear_keybuf();
5441 rest(1);
5442 }
5443
5444 return D_REDRAW;
5445 }
5446
5447 return jwin_button_proc(msg,d,c);
5448 }
5449
5450 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5451 {
5452 switch(msg)
5453 {
5454 case MSG_KEY:
5455 case MSG_CLICK:
5456
5457 kb_getkey(d);
5458
5459 while(gui_mouse_b()) {
5460 clear_keybuf();
5461 rest(1);
5462 }
5463
5464 return D_REDRAW;
5465 }
5466
5467 return jwin_button_proc(msg,d,c);
5468 }
5469
5470 //Only used in keyboard settings dialogues to clear keys.
5471 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5472 {
5473 switch(msg)
5474 {
5475 case MSG_KEY:
5476 case MSG_CLICK:
5477
5478 kb_clearkey(d);
5479
5480 while(gui_mouse_b()) {
5481 clear_keybuf();
5482 rest(1);
5483 }
5484
5485 return D_REDRAW;
5486 }
5487
5488 return jwin_button_proc(msg,d,c);
5489 }
5490
5491 void j_getbtn(DIALOG *d)
5492 {
5493 d->flags|=D_SELECTED;
5494 scare_mouse();
5495 jwin_button_proc(MSG_DRAW,d,0);
5496 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5497 // text_mode(vc(11));
5498 int32_t y = gui_bmp->h/2 - 12;
5499 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5500 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5501 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5502 unscare_mouse();
5503
5504 update_hw_screen(true);
5505
5506 int32_t b = next_press_btn();
5507
5508 if(b>=0)
5509 *((int32_t*)d->dp3) = b;
5510
5511 d->flags&=~D_SELECTED;
5512
5513 if (player)
5514 player->joy_on = TRUE;
5515 }
5516
5517 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5518 {
5519 switch(msg)
5520 {
5521 case MSG_KEY:
5522 case MSG_CLICK:
5523
5524 j_getbtn(d);
5525
5526 while(gui_mouse_b()) {
5527 rest(1);
5528 clear_keybuf();
5529 }
5530
5531 return D_REDRAW;
5532 }
5533
5534 return jwin_button_proc(msg,d,c);
5535 }
5536
5537 //shnarf
5538 const char *key_str[] =
5539 {
5540 "(none) ", "a ", "b ", "c ",
5541 "d ", "e ", "f ", "g ",
5542 "h ", "i ", "j ", "k ",
5543 "l ", "m ", "n ", "o ",
5544 "p ", "q ", "r ", "s ",
5545 "t ", "u ", "v ", "w ",
5546 "x ", "y ", "z ", "0 ",
5547 "1 ", "2 ", "3 ", "4 ",
5548 "5 ", "6 ", "7 ", "8 ",
5549 "9 ", "num 0 ", "num 1 ", "num 2 ",
5550 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5551 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5552 "f2 ", "f3 ", "f4 ", "f5 ",
5553 "f6 ", "f7 ", "f8 ", "f9 ",
5554 "f10 ", "f11 ", "f12 ", "esc ",
5555 "~ ", "- ", "= ", "backspace ",
5556 "tab ", "{ ", "} ", "enter ",
5557 ": ", "quote ", "\\ ", "\\ (2) ",
5558 ", ", ". ", "/ ", "space ",
5559 "insert ", "delete ", "home ", "end ",
5560 "page up ", "page down ", "left ", "right ",
5561 "up ", "down ", "num / ", "num * ",
5562 "num - ", "num + ", "num delete ", "num enter ",
5563 "print screen ", "pause ", "abnt c1 ", "yen ",
5564 "kana ", "convert ", "no convert ", "at ",
5565 "circumflex ", ": (2) ", "kanji ", "num = ",
5566 "back quote ", "; ", "command ", "unknown (0) ",
5567 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5568 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5569 "right shift ", "left control ", "right control", "alt ",
5570 "alt gr ", "left win ", "right win ", "menu ",
5571 "scroll lock ", "number lock ", "caps lock ", "MAX"
5572 };
5573
5574
5575 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5576 //extern int32_t zcmusic_bufsz;
5577
5578 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5579 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5580
5581 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5582 {
5583 //these are here to bypass compiler warnings about unused arguments
5584 c=c;
5585
5586 if(msg==MSG_DRAW)
5587 {
5588 switch(d->w)
5589 {
5590 case 0:
5591 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5592 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5593 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5594 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5595 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5596 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5597 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5598 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5599 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5600 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5601 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5602 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5603 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5604 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5605 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5606 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5607 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5608 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5609 break;
5610
5611 case 1:
5612 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5613 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5614 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5615 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5616 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5617 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5618 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5619 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5620 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5621 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5622 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5623 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5624 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5625 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5626 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5627 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5628 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5629 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5630 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5631 break;
5632
5633 case 2:
5634 sprintf(str_a," %3d",midi_volume);
5635 sprintf(str_b," %3d",digi_volume);
5636 sprintf(str_l," %3d",emusic_volume);
5637 sprintf(str_m," %3dKB",zcmusic_bufsz);
5638 sprintf(str_r," %3d",sfx_volume);
5639 strcpy(str_s,pan_str[pan_style]);
5640 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5641 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5642 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5643 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5644 break;
5645 }
5646 }
5647
5648 return D_O_K;
5649 }
5650
5651 int32_t set_vol(void *dp3, int32_t d2)
5652 {
5653 switch(((int32_t*)dp3)[0])
5654 {
5655 case 0:
5656 midi_volume = zc_min(d2<<3,255);
5657 break;
5658
5659 case 1:
5660 digi_volume = zc_min(d2<<3,255);
5661 break;
5662
5663 case 2:
5664 emusic_volume = zc_min(d2<<3,255);
5665 break;
5666
5667 case 3:
5668 sfx_volume = zc_min(d2<<3,255);
5669 break;
5670 }
5671
5672 scare_mouse();
5673 // text_mode(vc(11));
5674 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5675 unscare_mouse();
5676 return D_O_K;
5677 }
5678
5679 int32_t set_pan(void *dp3, int32_t d2)
5680 {
5681 pan_style = vbound(d2,0,3);
5682 scare_mouse();
5683 // text_mode(vc(11));
5684 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5685 unscare_mouse();
5686 return D_O_K;
5687 }
5688
5689 int32_t set_buf(void *dp3, int32_t d2)
5690 {
5691 scare_mouse();
5692 // text_mode(vc(11));
5693 zcmusic_bufsz = d2 + 1;
5694 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5695 unscare_mouse();
5696 return D_O_K;
5697 }
5698
5699 static int32_t gamepad_btn_list[] =
5700 {
5701 6,
5702 7,8,9,10,11,12,13,14,15,16,17,
5703 18,19,20,21,22,23,24,25,26,27,28,
5704 29,30,31,32,33,34,35,36,37,38,39,
5705 -1
5706 };
5707
5708 static int32_t gamepad_dirs_list[] =
5709 {
5710 40,41,42,43,
5711 44,45,46,47,
5712 48,49,50,51,
5713 52,53,54,55,
5714 56,
5715 -1
5716 };
5717
5718 static TABPANEL gamepad_tabs[] =
5719 {
5720 // (text)
5721 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5722 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5723 { NULL, 0, NULL, 0, NULL }
5724 };
5725
5726 static DIALOG gamepad_dlg[] =
5727 {
5728 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5729 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5730 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5731 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5732 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5733 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5734 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5735 // 6
5736 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5737 // 7
5738 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5739 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5740 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5741 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5742 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5743 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5744 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5745 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5746 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5747 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5748 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5749 // 18
5750 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5751 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5752 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5753 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5754 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5755 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5756 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5757 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5758 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5759 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5760 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5761 // 29
5762 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5763 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5764 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5765 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5766 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5767 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5768 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5769 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5770 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5771 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5772 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5773 // 40
5774 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5775 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5776 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5777 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5778 // 44
5779 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5780 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5781 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5782 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5783 // 48
5784 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5785 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5786 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5787 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5788 // 52
5789 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5790 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5791 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5792 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5793 // 56
5794 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5795 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5796 };
5797
5798 static int32_t keyboard_keys_list[] =
5799 {
5800 6,7,8,9,10,
5801 11,12,13,14,15,16,17,18,19,20,
5802 21,22,23,24,25,26,27,28,29,30,
5803 31,32,33,34,35,36,37,38,39,40,
5804 -1
5805 };
5806
5807 static int32_t keyboard_dirs_list[] =
5808 {
5809 41,42,43,44,
5810 45,46,47,48,
5811 49,50,51,52,
5812 53,54,55,56,
5813 -1
5814 };
5815
5816 static int32_t keyboard_mods_list[] =
5817 {
5818 57,58,59,60,
5819 61,62,63,64,
5820 65,66,67,68,
5821 69,70,71,72,
5822 -1
5823 };
5824
5825 static TABPANEL keyboard_control_tabs[] =
5826 {
5827 // (text)
5828 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5829 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5830 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5831 { NULL, 0, NULL, 0, NULL }
5832 };
5833
5834 static DIALOG keyboard_control_dlg[] =
5835 {
5836 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5837 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5838 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5839 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5840 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5841 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5842 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5843 // Keys
5844 // 6
5845 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5846 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5847 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5848 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5849 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5850 // 11
5851 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5852 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5853 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5854 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5855 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5856 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5857 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5858 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5859 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5860 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5861 // 21
5862 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5863 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5864 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5865 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5866 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5867 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5868 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5869 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5870 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5871 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5872 // 31
5873 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5874 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5875 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5876 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5877 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5878 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5879 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5880 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5881 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5882 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5883 // Dirs
5884 // 41
5885 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5886 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5887 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5888 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5889 // 45
5890 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5891 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5892 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5893 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5894 // 49
5895 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5896 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5897 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5898 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5899 // 53
5900 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5901 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5902 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5903 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5904 // Mods
5905 // 57
5906 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5907 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5908 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5909 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5910 // 61
5911 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5912 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5913 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5914 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5915 // 65
5916 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5917 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5918 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5919 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5920 // 69
5921 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5922 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5923 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5924 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5925 // 73
5926 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5927 };
5928
5929 /*
5930 int32_t midi_dp[3] = {0,147,104};
5931 int32_t digi_dp[3] = {1,147,120};
5932 int32_t pan_dp[3] = {0,147,136};
5933 int32_t buf_dp[3] = {0,147,152};
5934 */
5935 int32_t midi_dp[3] = {0,0,0};
5936 int32_t digi_dp[3] = {1,0,0};
5937 int32_t emus_dp[3] = {2,0,0};
5938 int32_t buf_dp[3] = {0,0,0};
5939 int32_t sfx_dp[3] = {3,0,0};
5940 int32_t pan_dp[3] = {0,0,0};
5941
5942 static DIALOG sound_dlg[] =
5943 {
5944 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5945 28 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5946 28 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5947 28 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5948 28 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5949 28 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5950 28 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5951 28 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5952 28 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5953 28 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5954 28 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5955 // 10
5956 28 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5957 28 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5958 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5959 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5960 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5961 28 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5962 28 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5963 28 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5964 28 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5965 28 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5966 //20
5967 28 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5968 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5969 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5970 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5971 28 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5972 28 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5973 28 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5974 28 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5975 28 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5976 28 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5977 //30
5978 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5979 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5980 28 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5981 28 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5982 };
5983
5984 char zc_builddate[80];
5985 char zc_aboutstr[80];
5986
5987 static DIALOG about_dlg[] =
5988 {
5989 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5990 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5991 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5992 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5993 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5994 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5995 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5996 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5997 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5998 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5999 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6000 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6001 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6002 };
6003
6004
6005 static DIALOG quest_dlg[] =
6006 {
6007 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6008 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6009 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6010 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6011 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6012 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6013 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
6014 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6015 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6016 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6017 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6018 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6019 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6020 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6021 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6022 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6023 };
6024
6025 static DIALOG triforce_dlg[] =
6026 {
6027 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6028 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6029 // 1
6030 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6031 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6032 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6033 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6034 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6035 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6036 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6037 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6038 // 9
6039 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6040 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6041 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6042 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6043 };
6044
6045 /*static DIALOG equip_dlg[] =
6046 {
6047 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6048 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6049 // 1
6050 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6051 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6052 // 3
6053 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6054 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6055 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6056 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6057 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6058 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6059 // 9
6060 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6061 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6062 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6063 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6064 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6065 // 14
6066 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6067 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6068 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6069 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6070 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6071 // 19
6072 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6073 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6074 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6075 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6076 // 23
6077 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6078 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6079 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6080 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6081 // 27
6082 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6083 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6084 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6085 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6086 // 31
6087 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6088 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6089 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6090 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6091 // 35
6092 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6093 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6094 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6095 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6096 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6097 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6098 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6099 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6100 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6101 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6102 };
6103
6104 static DIALOG items_dlg[] =
6105 {
6106 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6107 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6108 //1
6109 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6110 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6111 // 3
6112 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6113 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6114 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6115 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6116 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6117 // 8
6118 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6119 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6120 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6121 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6122 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6123 // 13
6124 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6125 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6126 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6127 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6128 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6129 // 18
6130 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6131 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6132 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6133 // 21
6134 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6135 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6136 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6137 // 24
6138 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6139 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6140 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6141 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6142 // 28
6143 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6144 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6145 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6146 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6147 // 32
6148 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6149 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6150 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6151 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6152 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6153 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6154 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6155 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6156 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6157 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6158 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6159 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6160 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6161 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6162 //45
6163 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6164 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6165 };*/
6166
6167
6168
6169 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6170 {
6171 go();
6172 int32_t ret=0;
6173 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6174 comeback();
6175 return ret != 0;
6176 }
6177
6178
6179 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6180 {
6181 if(def!=modulepath)
6182 strcpy(modulepath,def);
6183
6184 if(!usefilename)
6185 {
6186 int32_t i=(int32_t)strlen(modulepath);
6187
6188 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6189 modulepath[i--]=0;
6190 }
6191
6192 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6193 int32_t ret=0;
6194 int32_t sel=0;
6195
6196 if(list==NULL)
6197 {
6198 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6199 }
6200 else
6201 {
6202 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6203 }
6204
6205 return ret!=0;
6206 }
6207
6208 //The Dialogue that loads a ZMOD Module File
6209 int32_t zc_load_zmod_module_file()
6210 {
6211 if ( Playing )
6212 {
6213 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6214 return -1;
6215 }
6216 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6217 return D_CLOSE;
6218
6219 FILE *tempmodule = fopen(modulepath,"r");
6220
6221 if(tempmodule == NULL)
6222 {
6223 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6224 return -1;
6225 }
6226
6227
6228 //Set the module path:
6229 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6230 strcpy(moduledata.module_name, modulepath);
6231 al_trace("New Module Path is: %s \n", moduledata.module_name);
6232 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6233 zcm.init(true); //Load the module values.
6234 moduledata.refresh_title_screen = 1;
6235 // refresh_select_screen = 1;
6236 build_biic_list();
6237 return D_O_K;
6238 }
6239
6240 static DIALOG module_info_dlg[] =
6241 {
6242 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6243
6244
6245 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6246 //1
6247 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6248 //2
6249 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6250 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6251 //4
6252 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6253 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6254 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6255 //7
6256
6257 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6258 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6259 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6260 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6261 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6262 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6263 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6264 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6265 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6266
6267 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6268 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6269 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6270 };
6271
6272 void about_zcplayer_module(const char *prompt,int32_t initialval)
6273 {
6274
6275 module_info_dlg[0].dp2 = lfont;
6276 if ( moduledata.moduletitle[0] != 0 )
6277 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6278
6279 if ( moduledata.moduleauthor[0] != 0 )
6280 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6281
6282 if ( moduledata.moduleinfo0[0] != 0 )
6283 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6284 if ( moduledata.moduleinfo1[0] != 0 )
6285 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6286 if ( moduledata.moduleinfo2[0] != 0 )
6287 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6288 if ( moduledata.moduleinfo3[0] != 0 )
6289 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6290 if ( moduledata.moduleinfo4[0] != 0 )
6291 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6292
6293 char module_date[255];
6294 memset(module_date, 0, sizeof(module_date));
6295 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6296 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6297
6298
6299
6300 char module_vers[255];
6301 memset(module_vers, 0, sizeof(module_vers));
6302 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6303
6304
6305 //sprintf(tilecount,"%d",1);
6306
6307 char module_build[255];
6308 memset(module_build, 0, sizeof(module_build));
6309 if ( moduledata.modbeta )
6310 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6311 else
6312 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6313
6314 module_info_dlg[12].dp = (char*)module_date;
6315 module_info_dlg[13].dp = (char*)module_vers;
6316 module_info_dlg[14].dp = (char*)module_build;
6317
6318 if(is_large)
6319 large_dialog(module_info_dlg);
6320
6321 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6322 jwin_center_dialog(module_info_dlg);
6323
6324
6325 }
6326
6327 int32_t onAbout_ZCP_Module()
6328 {
6329 about_zcplayer_module("About Module (.zmod)", 0);
6330 return D_O_K;
6331 }
6332
6333 //New Modules Menu for 2.55+
6334 static MENU zcmodule_menu[] =
6335 {
6336 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6337 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6338
6339 { NULL, NULL, NULL, 0, NULL }
6340 };
6341
6342 int32_t onToggleRecordingNewSaves()
6343 {
6344 if (zc_get_config("zeldadx", "replay_new_saves", false))
6345 {
6346 zc_set_config("zeldadx", "replay_new_saves", false);
6347 }
6348 else
6349 {
6350 zc_set_config("zeldadx", "replay_new_saves", true);
6351 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6352 NULL,NULL,"OK",NULL,13,27,lfont);
6353 }
6354 return D_O_K;
6355 }
6356
6357 int32_t onToggleSnapshotAllFrames()
6358 {
6359 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6360 return D_O_K;
6361 }
6362
6363 int32_t onStopReplayOrRecord()
6364 {
6365 if (replay_is_replaying())
6366 {
6367 replay_quit();
6368 }
6369 else if (replay_get_mode() == ReplayMode::Record)
6370 {
6371 if (!replay_get_meta_bool("test_mode"))
6372 {
6373 jwin_alert("Recording", "You cannot stop recording a save file.",
6374 NULL,NULL,"OK",NULL,13,27,lfont);
6375 return D_CLOSE;
6376 }
6377
6378 if (jwin_alert("Stop Recording",
6379 "Save replay to disk and stop recording?",
6380 "This will stop the recording.",
6381 NULL,
6382 "Yes","No",13,27,lfont) != 1)
6383 return D_CLOSE;
6384
6385 replay_save();
6386 replay_stop();
6387 }
6388 return D_O_K;
6389 }
6390
6391 static int32_t handle_on_load_replay(ReplayMode mode)
6392 {
6393 if (Playing)
6394 {
6395 if (jwin_alert("Replay - Warning!",
6396 "Loading a replay will exit the current game.",
6397 "All unsaved progress will be lost.",
6398 "Do you wish to continue?",
6399 "Yes","No",13,27,lfont) != 1)
6400 return D_CLOSE;
6401 }
6402
6403 std::string mode_string = replay_mode_to_string(mode);
6404 mode_string[0] = std::toupper(mode_string[0]);
6405
6406 std::string line_1 = "Select a replay file to play back.";
6407 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6408 std::string line_3 = "You can stop the replay and take over manually any time.";
6409 if (mode == ReplayMode::Update)
6410 {
6411 line_1 = "Select a replay file to update.";
6412 line_2 = "WARNING: be sure to back up the zplay file";
6413 line_3 = "and verify that the updated replay works as expected!";
6414 }
6415
6416 if (jwin_alert(mode_string.c_str(),
6417 line_1.c_str(),
6418 line_2.c_str(),
6419 line_3.c_str(),
6420 "OK","Nevermind",13,27,lfont) == 1)
6421 {
6422 char replay_path[2048];
6423 strcpy(replay_path, "replays/");
6424 if (jwin_file_select_ex(
6425 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6426 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6427 return D_CLOSE;
6428
6429 replay_quit();
6430 load_replay_file_deferred(mode, replay_path);
6431 Quit = qRESET;
6432 return D_CLOSE;
6433 }
6434 return D_O_K;
6435 }
6436
6437 int32_t onLoadReplay()
6438 {
6439 return handle_on_load_replay(ReplayMode::Replay);
6440 }
6441
6442 int32_t onLoadReplayAssert()
6443 {
6444 return handle_on_load_replay(ReplayMode::Assert);
6445 }
6446
6447 int32_t onLoadReplayUpdate()
6448 {
6449 return handle_on_load_replay(ReplayMode::Update);
6450 }
6451
6452 int32_t onSaveReplay()
6453 {
6454 if (replay_get_mode() == ReplayMode::Record)
6455 {
6456 if (!replay_get_meta_bool("test_mode"))
6457 {
6458 if (jwin_alert("Save Replay",
6459 "This will save a copy of the replay up to this point.",
6460 "The official replay file will be untouched.",
6461 "Do you wish to continue?",
6462 "Yes","No",13,27,lfont) != 1)
6463 return D_CLOSE;
6464
6465 char replay_path[2048];
6466 strcpy(replay_path, replay_get_replay_path().string().c_str());
6467 if (jwin_file_select_ex(
6468 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6469 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6470 return D_CLOSE;
6471
6472 if (fileexists(replay_path))
6473 {
6474 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6475 NULL,NULL,"OK",NULL,13,27,lfont);
6476 return D_CLOSE;
6477 }
6478
6479 replay_save(replay_path);
6480 }
6481 else
6482 {
6483 replay_save();
6484 }
6485 }
6486 return D_O_K;
6487 }
6488
6489 static MENU replay_menu[] =
6490 {
6491 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6492 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6493 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6494 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6495 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6496 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6497 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6498
6499 { NULL, NULL, NULL, 0, NULL }
6500 };
6501
6502 static DIALOG credits_dlg[] =
6503 {
6504 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6505 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6506 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6507 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6508 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6509 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6510 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6511 };
6512
6513 28 static ListData dmap_list(dmaplist, &font);
6514
6515 static DIALOG goto_dlg[] =
6516 {
6517 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6518 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6519 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6520 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6521 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6522 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6523 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6524 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6525 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6526 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6527 };
6528
6529 int32_t onGoTo()
6530 {
6531 bool music = false;
6532 music = music;
6533 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6534
6535 goto_dlg[0].dp2=lfont;
6536 goto_dlg[4].d2=cheat_goto_dmap;
6537 goto_dlg[6].dp=cheat_goto_screen_str;
6538
6539 clear_keybuf();
6540
6541 if(is_large)
6542 large_dialog(goto_dlg);
6543
6544 if(zc_popup_dialog(goto_dlg,4)==1)
6545 {
6546 // dmap, screen
6547 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6548 };
6549
6550 return D_O_K;
6551 }
6552
6553 int32_t onGoToComplete()
6554 {
6555 if(!Playing)
6556 {
6557 return D_O_K;
6558 }
6559
6560 system_pal();
6561 music_pause();
6562 pause_all_sfx();
6563 show_mouse(screen);
6564 onGoTo();
6565 eat_buttons();
6566
6567 zc_readrawkey(KEY_ESC);
6568
6569 show_mouse(NULL);
6570 game_pal();
6571 music_resume();
6572 resume_all_sfx();
6573 return D_O_K;
6574 }
6575
6576 int32_t onCredits()
6577 {
6578 go();
6579
6580 BITMAP *win = create_bitmap_ex(8,222,110);
6581
6582 if(!win)
6583 return D_O_K;
6584
6585 int32_t c=0;
6586 int32_t l=0;
6587 int32_t ol=-1;
6588 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6589 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6590 PALETTE tmppal;
6591
6592 rti_gui.transparency_index = 1;
6593
6594 clear_to_color(win, rti_gui.transparency_index);
6595 draw_rle_sprite(win,rle,0,0);
6596 credits_dlg[0].dp2=lfont;
6597 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6598 credits_dlg[2].dp = win;
6599
6600 set_palette_range(black_palette,0,127,false);
6601
6602 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6603
6604 BITMAP* old_screen = screen;
6605 BITMAP* gui_bmp = zc_get_gui_bmp();
6606 ASSERT(gui_bmp);
6607 clear_to_color(gui_bmp, rti_gui.transparency_index);
6608 screen = gui_bmp;
6609
6610 while(update_dialog(p))
6611 {
6612 throttleFPS();
6613 ++c;
6614 l = zc_max((c>>1)-30,0);
6615
6616 if(l > rle->h)
6617 l = c = 0;
6618
6619 if(l > rle->h - 112)
6620 l = rle->h - 112;
6621
6622 clear_bitmap(win);
6623 draw_rle_sprite(win,rle,0,0-l);
6624
6625 if(c<=64)
6626 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6627
6628 set_palette_range(tmppal,0,127,false);
6629
6630 if(l!=ol)
6631 {
6632 scare_mouse();
6633 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6634 unscare_mouse();
6635 SCRFIX();
6636 ol=l;
6637 }
6638
6639 update_hw_screen();
6640 }
6641
6642 screen = old_screen;
6643 system_pal();
6644
6645 shutdown_dialog(p);
6646 destroy_bitmap(win);
6647 //comeback();
6648
6649 rti_gui.transparency_index = 0;
6650
6651 return D_O_K;
6652 }
6653
6654 const char *midilist(int32_t index, int32_t *list_size)
6655 {
6656 if(index<0)
6657 {
6658 *list_size=0;
6659
6660 for(int32_t i=0; i<MAXMIDIS; i++)
6661 if(tunes[i].data)
6662 ++(*list_size);
6663
6664 return NULL;
6665 }
6666
6667 int32_t i=0,m=0;
6668
6669 while(m<=index && i<=MAXMIDIS)
6670 {
6671 if(tunes[i].data)
6672 ++m;
6673
6674 ++i;
6675 }
6676
6677 --i;
6678
6679 if(i==MAXMIDIS && m<index)
6680 return "(null)";
6681
6682 return tunes[i].title;
6683 }
6684
6685 /* ------- MIDI info stuff -------- */
6686
6687 char *text;
6688 midi_info *zmi;
6689 bool dialog_running;
6690 bool listening;
6691
6692 void get_info(int32_t index);
6693
6694 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6695 {
6696 int32_t d2 = d->d2;
6697 int32_t ret = jwin_droplist_proc(msg,d,c);
6698
6699 if(d2!=d->d2)
6700 {
6701 get_info(d->d2);
6702 }
6703
6704 return ret;
6705 }
6706
6707 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6708 {
6709 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6710
6711 int32_t ret = jwin_button_proc(msg,d,c);
6712
6713 if(ret == D_CLOSE)
6714 {
6715 // get current midi index
6716 int32_t index = (d+(d->d1))->d2;
6717 int32_t i=0, m=0;
6718
6719 while(m<=index && i<=MAXMIDIS)
6720 {
6721 if(tunes[i].data)
6722 ++m;
6723
6724 ++i;
6725 }
6726
6727 --i;
6728 jukebox(i);
6729 listening = true;
6730 ret = D_O_K;
6731 }
6732
6733 return ret;
6734 }
6735
6736 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6737 {
6738 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6739
6740 int32_t ret = jwin_button_proc(msg,d,c);
6741
6742 if(ret == D_CLOSE)
6743 {
6744 // get current midi index
6745 int32_t index = (d+(d->d1))->d2;
6746 int32_t i=0, m=0;
6747
6748 while(m<=index && i<=MAXMIDIS)
6749 {
6750 if(tunes[i].data)
6751 ++m;
6752
6753 ++i;
6754 }
6755
6756 --i;
6757
6758 // get file name
6759
6760 int32_t sel=0;
6761 //struct ffblk f;
6762 char title[40] = "Save MIDI: ";
6763 char fname[2048];
6764 memset(fname,0,2048);
6765 static EXT_LIST list[] =
6766 {
6767 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6768 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6769 { NULL, NULL }
6770 };
6771
6772 strcpy(title+11, tunes[i].title);
6773 title[39] = '\0';
6774
6775 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6776 goto done;
6777
6778 if(exists(fname))
6779 {
6780 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6781 goto done;
6782 }
6783
6784 // save midi i
6785
6786 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6787 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6788
6789 done:
6790 chop_path(fname);
6791 ret = D_REDRAW;
6792 }
6793
6794 return ret;
6795 }
6796
6797 28 static ListData midi_list(midilist, &font);
6798
6799 static DIALOG midi_dlg[] =
6800 {
6801 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6802 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6803 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6804 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6805 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6806 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6807 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6808 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6809 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6810 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6811 };
6812
6813 void get_info(int32_t index)
6814 {
6815 int32_t i=0, m=0;
6816
6817 while(m<=index && i<=MAXMIDIS)
6818 {
6819 if(tunes[i].data)
6820 ++m;
6821
6822 ++i;
6823 }
6824
6825 --i;
6826
6827 if(i==MAXMIDIS && m<index)
6828 strcpy(text,"(null)");
6829 else
6830 {
6831 get_midi_info((MIDI*)tunes[i].data,zmi);
6832 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6833 }
6834
6835 midi_dlg[0].dp2=lfont;
6836 midi_dlg[3].dp = text;
6837 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6838 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6839
6840 if(dialog_running)
6841 {
6842 scare_mouse();
6843 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6844 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6845 unscare_mouse();
6846 }
6847 }
6848
6849 int32_t onMIDICredits()
6850 {
6851 text = (char*)malloc(4096);
6852 zmi = (midi_info*)malloc(sizeof(midi_info));
6853
6854 if(!text || !zmi)
6855 {
6856 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6857 return D_O_K;
6858 }
6859
6860 bool do_pause_midi = midi_pos >= 0 && currmidi;
6861 auto restore_midi = currmidi;
6862 if(do_pause_midi)
6863 {
6864 paused_midi_pos = midi_pos;
6865 stop_midi();
6866 midi_paused=true;
6867 midi_suspended = midissuspHALTED;
6868 }
6869
6870 midi_dlg[0].dp2=lfont;
6871 midi_dlg[2].d1 = 0;
6872 midi_dlg[2].d2 = 0;
6873 midi_dlg[4].flags = D_EXIT;
6874 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6875
6876 listening = false;
6877 dialog_running=false;
6878 get_info(0);
6879
6880 dialog_running=true;
6881
6882 if(is_large)
6883 large_dialog(midi_dlg);
6884
6885 zc_popup_dialog(midi_dlg,0);
6886 dialog_running=false;
6887
6888 if(listening)
6889 music_stop();
6890
6891 if(do_pause_midi)
6892 {
6893 midi_suspended = midissuspRESUME;
6894 currmidi = restore_midi;
6895 midi_pos = paused_midi_pos;
6896 }
6897
6898 if(text) free(text);
6899 if(zmi) free(zmi);
6900 return D_O_K;
6901 }
6902
6903 int32_t onAbout()
6904 {
6905 char buf1[80]={0};
6906 std::ostringstream oss;
6907 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6908 oss << buf1 << '\n';
6909 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6910 oss << buf1 << '\n';
6911 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6912 oss << buf1 << '\n';
6913 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6914 oss << buf1 << '\n';
6915 sprintf(buf1, "Tag: %s", getReleaseTag());
6916 oss << buf1 << '\n';
6917
6918 InfoDialog("About ZC", oss.str()).show();
6919 return D_O_K;
6920 }
6921
6922 int32_t onQuest()
6923 {
6924 char fname[100];
6925 strcpy(fname, get_filename(qstpath));
6926 quest_dlg[0].dp2=lfont;
6927 quest_dlg[1].dp = fname;
6928
6929 if(QHeader.quest_number==0)
6930 sprintf(str_a,"Custom");
6931 else
6932 sprintf(str_a,"%d",QHeader.quest_number);
6933
6934 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6935
6936 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6937 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6938
6939 if(is_large)
6940 large_dialog(quest_dlg);
6941
6942 zc_popup_dialog(quest_dlg, 0);
6943 return D_O_K;
6944 }
6945
6946 void call_vidmode_dlg();
6947 int32_t onVidMode()
6948 {
6949 call_vidmode_dlg();
6950 return D_O_K;
6951 }
6952
6953 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6954 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6955 //Added an extra statement, so that if the key is cleared to 0, the cleared
6956 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6957
6958 void load_ukeys(int32_t* arr)
6959 {
6960 arr[ukey_a] = Akey;
6961 arr[ukey_b] = Bkey;
6962 arr[ukey_s] = Skey;
6963 arr[ukey_l] = Lkey;
6964 arr[ukey_r] = Rkey;
6965 arr[ukey_p] = Pkey;
6966 arr[ukey_ex1] = Exkey1;
6967 arr[ukey_ex2] = Exkey2;
6968 arr[ukey_ex3] = Exkey3;
6969 arr[ukey_ex4] = Exkey4;
6970 arr[ukey_du] = DUkey;
6971 arr[ukey_dd] = DDkey;
6972 arr[ukey_dl] = DLkey;
6973 arr[ukey_dr] = DRkey;
6974 arr[ukey_mod1a] = cheat_modifier_keys[0];
6975 arr[ukey_mod1b] = cheat_modifier_keys[1];
6976 arr[ukey_mod2a] = cheat_modifier_keys[2];
6977 arr[ukey_mod2b] = cheat_modifier_keys[3];
6978 };
6979
6980 static const char* ukey_names[] = {
6981 "A", "B", "Start", "L", "R", "Map",
6982 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6983 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6984 "Cheat Mod R1", "Cheat Mod R2",
6985 };
6986 std::string get_ukey_name(int32_t k)
6987 {
6988 if (k < num_ukey) return ukey_names[k];
6989 return "";
6990 }
6991
6992 int32_t onKeyboard()
6993 {
6994 int32_t a = Akey;
6995 int32_t b = Bkey;
6996 int32_t s = Skey;
6997 int32_t l = Lkey;
6998 int32_t r = Rkey;
6999 int32_t p = Pkey;
7000 int32_t ex1 = Exkey1;
7001 int32_t ex2 = Exkey2;
7002 int32_t ex3 = Exkey3;
7003 int32_t ex4 = Exkey4;
7004 int32_t du = DUkey;
7005 int32_t dd = DDkey;
7006 int32_t dl = DLkey;
7007 int32_t dr = DRkey;
7008 int32_t mod1a = cheat_modifier_keys[0];
7009 int32_t mod1b = cheat_modifier_keys[1];
7010 int32_t mod2a = cheat_modifier_keys[2];
7011 int32_t mod2b = cheat_modifier_keys[3];
7012 bool done=false;
7013 int32_t ret;
7014
7015 keyboard_control_dlg[0].dp2=lfont;
7016
7017 if(is_large)
7018 large_dialog(keyboard_control_dlg);
7019
7020 while(!done)
7021 {
7022 ret = zc_popup_dialog(keyboard_control_dlg,3);
7023
7024 if(ret==3) // OK
7025 {
7026 int32_t ukeys[num_ukey];
7027 load_ukeys(ukeys);
7028 std::vector<std::string> uniqueError;
7029 for(int32_t q = 0; q < num_ukey; ++q)
7030 {
7031 for(int32_t p = q+1; p < num_ukey; ++p)
7032 {
7033 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7034 {
7035 char buf[64];
7036 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7037 std::string str(buf);
7038 uniqueError.push_back(str);
7039 }
7040 }
7041 }
7042 if(uniqueError.size() == 0)
7043 {
7044 done = true;
7045 save_control_configs(true);
7046 }
7047 else
7048 {
7049 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7050 box_out("Cannot have duplicate keybinds!"); box_eol();
7051 for(std::vector<std::string>::iterator it = uniqueError.begin();
7052 it != uniqueError.end(); ++it)
7053 {
7054 box_out((*it).c_str()); box_eol();
7055 }
7056 box_end(true);
7057 }
7058 /* Old uniqueness check
7059 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7060 bool unique = true;
7061 addToHash(A,unique,keyhash);
7062 addToHash(B,unique,keyhash);
7063 addToHash(S,unique,keyhash);
7064 addToHash(L,unique,keyhash);
7065 addToHash(R,unique,keyhash);
7066 addToHash(P,unique,keyhash);
7067 addToHash(DU,unique,keyhash);
7068 addToHash(DD,unique,keyhash);
7069 addToHash(DL,unique,keyhash);
7070 addToHash(DR,unique,keyhash);
7071
7072 if(keyhash->find(Exkey1) == keyhash->end())
7073 {
7074 (*keyhash)[Exkey1]=true;
7075 }
7076 else
7077 {
7078 if ( Exkey1 != 0 ) unique = false;
7079 }
7080
7081 if(keyhash->find(Exkey2) == keyhash->end())
7082 {
7083 (*keyhash)[Exkey2]=true;
7084 }
7085 else
7086 {
7087 if ( Exkey2 != 0 ) unique = false;
7088 }
7089
7090 if(keyhash->find(Exkey3) == keyhash->end())
7091 {
7092 (*keyhash)[Exkey3]=true;
7093 }
7094 else
7095 {
7096 if ( Exkey3 != 0 ) unique = false;
7097 }
7098
7099 if(keyhash->find(Exkey4) == keyhash->end())
7100 {
7101 (*keyhash)[Exkey4]=true;
7102 }
7103 else
7104 {
7105 if ( Exkey4 != 0 )unique = false;
7106 }
7107 //modifier keys
7108 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7109 {
7110 (*keyhash)[cheat_modifier_keys[0]]=true;
7111 }
7112 else
7113 {
7114 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7115 }
7116 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7117 {
7118 (*keyhash)[cheat_modifier_keys[1]]=true;
7119 }
7120 else
7121 {
7122 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7123 }
7124 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7125 {
7126 (*keyhash)[cheat_modifier_keys[2]]=true;
7127 }
7128 else
7129 {
7130 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7131 }
7132 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7133 {
7134 (*keyhash)[cheat_modifier_keys[3]]=true;
7135 }
7136 else
7137 {
7138 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7139 }
7140
7141 delete keyhash;
7142
7143 if(unique)
7144 done=true;
7145 else
7146 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7147 */
7148 }
7149 else // Cancel
7150 {
7151 Akey = a;
7152 Bkey = b;
7153 Skey = s;
7154 Lkey = l;
7155 Rkey = r;
7156 Pkey = p;
7157 Exkey1 = ex1;
7158 Exkey2 = ex2;
7159 Exkey3 = ex3;
7160 Exkey4 = ex4;
7161 DUkey = du;
7162 DDkey = dd;
7163 DLkey = dl;
7164 DRkey = dr;
7165 cheat_modifier_keys[0] = mod1a;
7166 cheat_modifier_keys[1] = mod1b;
7167 cheat_modifier_keys[2] = mod2a;
7168 cheat_modifier_keys[3] = mod2b;
7169
7170 done=true;
7171 }
7172
7173 rest(1);
7174 }
7175
7176 return D_O_K;
7177 }
7178
7179 int32_t onGamepad()
7180 {
7181 int32_t a = Abtn;
7182 int32_t b = Bbtn;
7183 int32_t s = Sbtn;
7184 int32_t l = Lbtn;
7185 int32_t r = Rbtn;
7186 int32_t m = Mbtn;
7187 int32_t p = Pbtn;
7188 int32_t ex1 = Exbtn1;
7189 int32_t ex2 = Exbtn2;
7190 int32_t ex3 = Exbtn3;
7191 int32_t ex4 = Exbtn4;
7192 int32_t up = DUbtn;
7193 int32_t down = DDbtn;
7194 int32_t left = DLbtn;
7195 int32_t right = DRbtn;
7196
7197 gamepad_dlg[0].dp2=lfont;
7198 if(analog_movement)
7199 gamepad_dlg[56].flags|=D_SELECTED;
7200 else
7201 gamepad_dlg[56].flags&=~D_SELECTED;
7202
7203 if(is_large)
7204 large_dialog(gamepad_dlg);
7205
7206 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7207
7208 if(ret == 4) //OK
7209 {
7210 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7211 save_control_configs(false);
7212 }
7213 else //Cancel
7214 {
7215 Abtn = a;
7216 Bbtn = b;
7217 Sbtn = s;
7218 Lbtn = l;
7219 Rbtn = r;
7220 Mbtn = m;
7221 Pbtn = p;
7222 Exbtn1 = ex1;
7223 Exbtn2 = ex2;
7224 Exbtn3 = ex3;
7225 Exbtn4 = ex4;
7226 DUbtn = up;
7227 DDbtn = down;
7228 DLbtn = left;
7229 DRbtn = right;
7230 }
7231
7232 return D_O_K;
7233 }
7234
7235 int32_t onSound()
7236 {
7237 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7238 {
7239 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7240 }
7241 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7242 {
7243 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7244 }
7245 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7246 {
7247 emusic_volume = (int32_t)FFCore.usr_music_volume;
7248 }
7249 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7250 {
7251 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7252 }
7253 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7254 {
7255 pan_style = (int32_t)FFCore.usr_panstyle;
7256 }
7257
7258 int32_t m = midi_volume;
7259 int32_t d = digi_volume;
7260 int32_t e = emusic_volume;
7261 int32_t b = zcmusic_bufsz;
7262 int32_t s = sfx_volume;
7263 int32_t p = pan_style;
7264 pan_style = vbound(pan_style,0,3);
7265
7266 sound_dlg[0].dp2=lfont;
7267
7268 if(is_large)
7269 large_dialog(sound_dlg);
7270
7271 midi_dp[1] = sound_dlg[6].x;
7272 midi_dp[2] = sound_dlg[6].y;
7273 digi_dp[1] = sound_dlg[7].x;
7274 digi_dp[2] = sound_dlg[7].y;
7275 emus_dp[1] = sound_dlg[8].x;
7276 emus_dp[2] = sound_dlg[8].y;
7277 buf_dp[1] = sound_dlg[9].x;
7278 buf_dp[2] = sound_dlg[9].y;
7279 sfx_dp[1] = sound_dlg[10].x;
7280 sfx_dp[2] = sound_dlg[10].y;
7281 pan_dp[1] = sound_dlg[11].x;
7282 pan_dp[2] = sound_dlg[11].y;
7283 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7284 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7285 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7286 sound_dlg[18].d2 = zcmusic_bufsz;
7287 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7288 sound_dlg[20].d2 = pan_style;
7289
7290 int32_t ret = zc_popup_dialog(sound_dlg,1);
7291
7292 if(ret==2)
7293 {
7294 master_volume(digi_volume,midi_volume);
7295
7296 for(int32_t i=0; i<WAV_COUNT; ++i)
7297 {
7298 //allegro assertion fails when passing in -1 as voice -DD
7299 if(sfx_voice[i] > 0)
7300 voice_set_volume(sfx_voice[i], sfx_volume);
7301 }
7302 zc_set_config(sfx_sect,"digi",digi_volume);
7303 zc_set_config(sfx_sect,"midi",midi_volume);
7304 zc_set_config(sfx_sect,"sfx",sfx_volume);
7305 zc_set_config(sfx_sect,"emusic",emusic_volume);
7306 zc_set_config(sfx_sect,"pan",pan_style);
7307 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7308 }
7309 else
7310 {
7311 midi_volume = m;
7312 digi_volume = d;
7313 emusic_volume = e;
7314 zcmusic_bufsz = b;
7315 sfx_volume = s;
7316 pan_style = p;
7317 }
7318
7319 return D_O_K;
7320 }
7321
7322 int32_t queding(char const* s1, char const* s2, char const* s3)
7323 {
7324 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7325 }
7326
7327 int32_t onQuit()
7328 {
7329 if(Playing)
7330 {
7331 int32_t ret=0;
7332
7333 if(get_bit(quest_rules, qr_NOCONTINUE))
7334 {
7335 if(standalone_mode)
7336 {
7337 ret=queding("End current game?",
7338 "The continue screen is disabled; the game",
7339 "will be reloaded from the last save.");
7340 }
7341 else
7342 {
7343 ret=queding("End current game?",
7344 "The continue screen is disabled. You will",
7345 "be returned to the file select screen.");
7346 }
7347 }
7348 else
7349 ret=queding("End current game?",NULL,NULL);
7350
7351 if(ret==1)
7352 {
7353 disableClickToFreeze=false;
7354 Quit=qQUIT;
7355
7356 // Trying to evade a door repair charge?
7357 if(repaircharge)
7358 {
7359 game->change_drupy(-repaircharge);
7360 repaircharge=0;
7361 }
7362
7363 return D_CLOSE;
7364 }
7365 }
7366
7367 return D_O_K;
7368 }
7369
7370 int32_t onTryQuitMenu()
7371 {
7372 return onTryQuit(true);
7373 }
7374
7375 int32_t onTryQuit(bool inMenu)
7376 {
7377 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7378 {
7379 if(get_bit(quest_rules,qr_OLD_F6))
7380 {
7381 if(inMenu) onQuit();
7382 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7383 }
7384 else
7385 {
7386 disableClickToFreeze=false;
7387 GameFlags |= GAMEFLAG_TRYQUIT;
7388 }
7389 return D_CLOSE;
7390 }
7391
7392 return D_O_K;
7393 }
7394
7395 int32_t onReset()
7396 {
7397 if(queding(" Reset system? ",NULL,NULL)==1)
7398 {
7399 disableClickToFreeze=false;
7400 Quit=qRESET;
7401 replay_quit();
7402 return D_CLOSE;
7403 }
7404
7405 return D_O_K;
7406 }
7407
7408 int32_t onExit()
7409 {
7410 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7411 {
7412 Quit=qEXIT;
7413 return D_CLOSE;
7414 }
7415
7416 return D_O_K;
7417 }
7418
7419 int32_t onTitle_NES()
7420 {
7421 title_version=0;
7422 zc_set_config(cfg_sect,"title",title_version);
7423 return D_O_K;
7424 }
7425 int32_t onTitle_DX()
7426 {
7427 title_version=1;
7428 zc_set_config(cfg_sect,"title",title_version);
7429 return D_O_K;
7430 }
7431 int32_t onTitle_25()
7432 {
7433 title_version=2;
7434 zc_set_config(cfg_sect,"title",title_version);
7435 return D_O_K;
7436 }
7437
7438 int32_t onDebug()
7439 {
7440 if(debug_enabled)
7441 set_debug(!get_debug());
7442 return D_O_K;
7443 }
7444
7445 int32_t onHeartBeep()
7446 {
7447 heart_beep=!heart_beep;
7448 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7449 return D_O_K;
7450 }
7451
7452 int32_t onSaveIndicator()
7453 {
7454 use_save_indicator=!use_save_indicator;
7455 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7456 return D_O_K;
7457 }
7458
7459 int32_t onEpilepsy()
7460 {
7461 if(jwin_alert3(
7462 "Epilepsy Flash Reduction",
7463 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7464 "Disabling this will restore standard flash and wavy behaviour.",
7465 "Proceed?",
7466 "&Yes",
7467 "&No",
7468 NULL,
7469 'y',
7470 'n',
7471 0,
7472 lfont) == 1)
7473 {
7474 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7475 zc_set_config("zeldadx","checked_epilepsy",1);
7476 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7477 }
7478 return D_O_K;
7479 }
7480
7481 int32_t onTriforce()
7482 {
7483 for(int32_t i=0; i<MAXINITTABS; ++i)
7484 {
7485 init_tabs[i].flags&=~D_SELECTED;
7486 }
7487
7488 init_tabs[3].flags=D_SELECTED;
7489 return onCheatConsole();
7490 /*triforce_dlg[0].dp2=lfont;
7491 for(int32_t i=1; i<=8; i++)
7492 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7493
7494 if(zc_popup_dialog (triforce_dlg,-1)==9)
7495 {
7496 for(int32_t i=1; i<=8; i++)
7497 {
7498 game->lvlitems[i] &= ~liTRIFORCE;
7499 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7500 }
7501 }
7502 return D_O_K;*/
7503 }
7504
7505 bool rc = false;
7506 /*
7507 int32_t onEquipment()
7508 {
7509 for (int32_t i=0; i<MAXINITTABS; ++i)
7510 {
7511 init_tabs[i].flags&=~D_SELECTED;
7512 }
7513 init_tabs[0].flags=D_SELECTED;
7514 return onCheatConsole();
7515 }
7516 */
7517
7518 int32_t onItems()
7519 {
7520 for(int32_t i=0; i<MAXINITTABS; ++i)
7521 {
7522 init_tabs[i].flags&=~D_SELECTED;
7523 }
7524
7525 init_tabs[1].flags=D_SELECTED;
7526 return onCheatConsole();
7527 }
7528
7529 static DIALOG getnum_dlg[] =
7530 {
7531 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7532 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7533 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7534 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7535 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7536 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7537 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7538 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7539 };
7540
7541 int32_t getnumber(const char *prompt,int32_t initialval)
7542 {
7543 char buf[20];
7544 sprintf(buf,"%d",initialval);
7545 getnum_dlg[0].dp=(void *)prompt;
7546 getnum_dlg[0].dp2=lfont;
7547 getnum_dlg[2].dp=buf;
7548
7549 if(is_large)
7550 large_dialog(getnum_dlg);
7551
7552 if(zc_popup_dialog(getnum_dlg,2)==3)
7553 return atoi(buf);
7554
7555 return initialval;
7556 }
7557
7558 int32_t onLife()
7559 {
7560 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7561 cheats_enqueue(Cheat::Life, value);
7562 return D_O_K;
7563 }
7564
7565 int32_t onHeartC()
7566 {
7567 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7568 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7569 cheats_enqueue(Cheat::MaxLife, max_life);
7570 cheats_enqueue(Cheat::Life, life);
7571 return D_O_K;
7572 }
7573
7574 int32_t onMagicC()
7575 {
7576 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7577 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7578 cheats_enqueue(Cheat::MaxMagic, max_magic);
7579 cheats_enqueue(Cheat::Magic, magic);
7580 return D_O_K;
7581 }
7582
7583 int32_t onRupies()
7584 {
7585 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7586 cheats_enqueue(Cheat::Rupies, value);
7587 return D_O_K;
7588 }
7589
7590 int32_t onMaxBombs()
7591 {
7592 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7593 cheats_enqueue(Cheat::MaxBombs, value);
7594 cheats_enqueue(Cheat::Bombs, value);
7595 return D_O_K;
7596 }
7597
7598 int32_t onRefillLife()
7599 {
7600 cheats_enqueue(Cheat::Life, game->get_maxlife());
7601 return D_O_K;
7602 }
7603 int32_t onRefillMagic()
7604 {
7605 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7606 return D_O_K;
7607 }
7608 int32_t onClock()
7609 {
7610 cheats_enqueue(Cheat::Clock);
7611 return D_O_K;
7612 }
7613
7614 int32_t onQstPath()
7615 {
7616 char path[2048];
7617
7618 chop_path(qstdir);
7619 strcpy(path,qstdir);
7620
7621 go();
7622
7623 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7624 {
7625 chop_path(path);
7626 fix_filename_case(path);
7627 fix_filename_slashes(path);
7628 strcpy(qstdir,path);
7629 strcpy(qstpath,qstdir);
7630 }
7631
7632 comeback();
7633 return D_O_K;
7634 }
7635
7636 #include "dialog/cheat_dialog.h"
7637 int32_t onCheat()
7638 {
7639 call_setcheat_dialog();
7640 game->set_cheat(maxcheat);
7641 if(cheat) game->did_cheat(true);
7642 return D_O_K;
7643 }
7644
7645 int32_t onCheatRupies()
7646 {
7647 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7648 return D_O_K;
7649 }
7650
7651 int32_t onCheatArrows()
7652 {
7653 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7654 return D_O_K;
7655 }
7656
7657 int32_t onCheatBombs()
7658 {
7659 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7660 return D_O_K;
7661 }
7662
7663 // *** screen saver
7664
7665 4800616 int32_t after_time()
7666 {
7667
1/2
✓ Branch 0 taken 4800616 times.
✗ Branch 1 not taken.
4800616 if(ss_enable == 0)
7668 return INT_MAX;
7669
7670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 0)
7671 return 5 * 60;
7672
7673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 3)
7674 return ss_after * 15 * 60;
7675
7676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800616 times.
4800616 if(ss_after <= 13)
7677 return (ss_after - 3) * 60 * 60;
7678
7679 4800616 return MAX_IDLE + 1;
7680 4800616 }
7681
7682 static const char *after_str[15] =
7683 {
7684 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7685 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7686 "Never"
7687 };
7688
7689 const char *after_list(int32_t index, int32_t *list_size)
7690 {
7691 if(index < 0)
7692 {
7693 *list_size = 15;
7694 return NULL;
7695 }
7696
7697 return after_str[index];
7698 }
7699
7700 28 static ListData after__list(after_list, &font);
7701
7702 static DIALOG scrsaver_dlg[] =
7703 {
7704 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7705 28 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7706 28 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7707 28 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7708 28 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7709 28 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7710 28 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7711 28 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7712 28 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7713 28 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7714 28 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7715 28 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7716 28 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7717 28 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7718 };
7719
7720 int32_t onScreenSaver()
7721 {
7722 scrsaver_dlg[0].dp2=lfont;
7723 int32_t oldcfgs[3];
7724 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7725 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7726 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7727
7728 if(is_large)
7729 large_dialog(scrsaver_dlg);
7730
7731 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7732
7733 if(ret == 8 || ret == 9)
7734 {
7735 ss_after = scrsaver_dlg[5].d1;
7736 ss_speed = scrsaver_dlg[6].d2;
7737 ss_density = scrsaver_dlg[7].d2;
7738 if(oldcfgs[0] != ss_after)
7739 zc_set_config(cfg_sect,"ss_after",ss_after);
7740 if(oldcfgs[1] != ss_speed)
7741 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7742 if(oldcfgs[2] != ss_density)
7743 zc_set_config(cfg_sect,"ss_density",ss_density);
7744 }
7745
7746 if(ret == 9)
7747 // preview Screen Saver
7748 {
7749 clear_keybuf();
7750 scare_mouse();
7751 Matrix(ss_speed, ss_density, 30);
7752 system_pal();
7753 unscare_mouse();
7754 }
7755
7756 return D_O_K;
7757 }
7758
7759 /***** Menus *****/
7760
7761 static MENU game_menu[] =
7762 {
7763 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7764 { (char *)"", NULL, NULL, 0, NULL },
7765 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7766 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7767 { (char *)"", NULL, NULL, 0, NULL },
7768 #ifdef __EMSCRIPTEN__
7769 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7770 #elif defined(ALLEGRO_MACOSX)
7771 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7772 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7773 #else
7774 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7775 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7776 #endif
7777 { NULL, NULL, NULL, 0, NULL }
7778 };
7779
7780 static MENU title_menu[] =
7781 {
7782 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7783 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7784 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7785 { NULL, NULL, NULL, 0, NULL }
7786 };
7787
7788 static MENU snapshot_format_menu[] =
7789 {
7790 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7791 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7792 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7793 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7794 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7795 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7796 { NULL, NULL, NULL, 0, NULL }
7797 };
7798
7799 static MENU controls_menu[] =
7800 {
7801 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7802 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7803 { NULL, NULL, NULL, 0, NULL }
7804 };
7805
7806 static MENU name_entry_mode_menu[] =
7807 {
7808 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7809 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7810 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7811 { NULL, NULL, NULL, 0, NULL }
7812 };
7813
7814 static void set_controls_menu_active()
7815 {
7816
7817 }
7818
7819 static MENU settings_menu[] =
7820 {
7821 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7822 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7823 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7824 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7825 { (char *)"", NULL, NULL, 0, NULL },
7826 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7827 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7828 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7829 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7830 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7831 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7832 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7833 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7834 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7835 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7836 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7837 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7838 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7839 { (char *)"", NULL, NULL, 0, NULL },
7840 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7841 { (char *)"", NULL, NULL, 0, NULL },
7842 { NULL, NULL, NULL, 0, NULL }
7843 };
7844
7845
7846 static MENU misc_menu[] =
7847 {
7848 { (char *)"&About...", onAbout, NULL, 0, NULL },
7849 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7850 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7851 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7852 { (char *)"", NULL, NULL, 0, NULL },
7853 //5
7854 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7855 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7856 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7857 { (char *)"", NULL, NULL, 0, NULL },
7858 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7859 //10
7860 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7861 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7862 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7863 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7864 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7865 //15
7866 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7867 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7868 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7869
7870 { NULL, NULL, NULL, 0, NULL }
7871 };
7872
7873 static MENU refill_menu[] =
7874 {
7875 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7876 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7877 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7878 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7879 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7880 { NULL, NULL, NULL, 0, NULL }
7881 };
7882
7883 static MENU show_menu[] =
7884 {
7885 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7886 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7887 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7888 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7889 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7890 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7891 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7892 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7893 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7894 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7895 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7896 { (char *)"", NULL, NULL, 0, NULL },
7897 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7898 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7899 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7900 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7901 { NULL, NULL, NULL, 0, NULL }
7902 };
7903
7904 static MENU cheat_menu[] =
7905 {
7906 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7907 { (char *)"", NULL, NULL, 0, NULL },
7908 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7909 { (char *)"", NULL, NULL, 0, NULL },
7910 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7911 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7912 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7913 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7914 { (char *)"", NULL, NULL, 0, NULL },
7915 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7916 { (char *)"", NULL, NULL, 0, NULL },
7917 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7918 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7919 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7920 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7921 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7922 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7923 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7924 { NULL, NULL, NULL, 0, NULL }
7925 };
7926
7927 static MENU fixes_menu[] =
7928 {
7929 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7930 { NULL, NULL, NULL, 0, NULL }
7931 };
7932
7933 #if DEVLEVEL > 0
7934 int32_t devLogging();
7935 int32_t devDebug();
7936 int32_t devTimestmp();
7937 #if DEVLEVEL > 1
7938 int32_t setCheat();
7939 #endif //DEVLEVEL > 1
7940 enum
7941 {
7942 dv_log,
7943 // dv_dbg,
7944 dv_tmpstmp,
7945 #if DEVLEVEL > 1
7946 dv_nil,
7947 dv_setcheat,
7948 #endif //DEVLEVEL > 1
7949 dv_max
7950 };
7951 static MENU dev_menu[] =
7952 {
7953 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7954 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7955 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7956 #if DEVLEVEL > 1
7957 { (char *)"", NULL, NULL, 0, NULL },
7958 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7959 #endif //DEVLEVEL > 1
7960 { NULL, NULL, NULL, 0, NULL }
7961 };
7962 int32_t devLogging()
7963 {
7964 dev_logging = !dev_logging;
7965 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7966 return D_O_K;
7967 }
7968 // int32_t devDebug()
7969 // {
7970 // dev_debug = !dev_debug;
7971 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7972 // return D_O_K;
7973 // }
7974 int32_t devTimestmp()
7975 {
7976 dev_timestmp = !dev_timestmp;
7977 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7978 return D_O_K;
7979 }
7980 #if DEVLEVEL > 1
7981 int32_t setCheat()
7982 {
7983 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7984 return D_O_K;
7985 }
7986 #endif //DEVLEVEL > 1
7987 #endif //DEVLEVEL > 0
7988
7989 MENU the_player_menu[] =
7990 {
7991 { (char *)"&Game", NULL, game_menu, 0, NULL },
7992 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7993 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7994 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7995 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7996 #if DEVLEVEL > 0
7997 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7998 #endif
7999 { NULL, NULL, NULL, 0, NULL }
8000 };
8001
8002 MENU the_player_menu2[] =
8003 {
8004 { (char *)"&Game", NULL, game_menu, 0, NULL },
8005 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8006 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8007 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8008 #if DEVLEVEL > 0
8009 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8010 #endif
8011 { NULL, NULL, NULL, 0, NULL }
8012 };
8013
8014 int32_t onMIDIPatch()
8015 {
8016 if(jwin_alert3(
8017 "Toggle Windows MIDI Fix",
8018 "This action will change whether ZC Player auto-restarts a MIDI at its",
8019 "last index if you move ZC Player out of focus, then back into focus.",
8020 "Proceed?",
8021 "&Yes",
8022 "&No",
8023 NULL,
8024 'y',
8025 'n',
8026 0,
8027 lfont) == 1)
8028 {
8029 midi_patch_fix = midi_patch_fix ? 0 : 1;
8030 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8031 }
8032 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8033 return D_O_K;
8034 }
8035
8036 int32_t onKeyboardEntry()
8037 {
8038 NameEntryMode=0;
8039 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8040 return D_O_K;
8041 }
8042
8043 int32_t onLetterGridEntry()
8044 {
8045 NameEntryMode=1;
8046 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8047 return D_O_K;
8048 }
8049
8050 int32_t onExtLetterGridEntry()
8051 {
8052 NameEntryMode=2;
8053 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8054 return D_O_K;
8055 }
8056
8057 static BITMAP* oldscreen;
8058 int32_t onFullscreenMenu()
8059 {
8060 // super hacks
8061 screen = oldscreen;
8062 if (onFullscreen() == D_REDRAW)
8063 {
8064 oldscreen = screen;
8065 }
8066 screen = menu_bmp;
8067 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8068 return D_O_K;
8069 }
8070
8071 28 void fix_menu()
8072 {
8073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(!debug_enabled)
8074 28 settings_menu[18].text = NULL;
8075 28 }
8076
8077 static DIALOG system_dlg[] =
8078 {
8079 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8080 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8081 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8082 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8083 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8084 #ifndef ALLEGRO_MACOSX
8085 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8086 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8087 #else
8088 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8089 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8090 #endif
8091 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8092 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8093 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8094 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8095 };
8096
8097 static DIALOG system_dlg2[] =
8098 {
8099 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8100 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8101 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8102 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8103 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8104 #ifndef ALLEGRO_MACOSX
8105 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8106 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8107 #else
8108 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8109 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8110 #endif
8111 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8112 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8113 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8115 };
8116
8117 void reset_snapshot_format_menu()
8118 {
8119 for(int32_t i=0; i<ssfmtMAX; ++i)
8120 {
8121 snapshot_format_menu[i].flags=0;
8122 }
8123 }
8124
8125 int32_t onSetSnapshotFormat()
8126 {
8127 switch(active_menu->text[1])
8128 {
8129 case 'B': //"&BMP"
8130 SnapshotFormat=0;
8131 break;
8132
8133 case 'G': //"&GIF"
8134 SnapshotFormat=1;
8135 break;
8136
8137 case 'J': //"&JPG"
8138 SnapshotFormat=2;
8139 break;
8140
8141 case 'P': //"&PNG"
8142 SnapshotFormat=3;
8143 break;
8144
8145 case 'C': //"PC&X"
8146 SnapshotFormat=4;
8147 break;
8148
8149 case 'T': //"&TGA"
8150 SnapshotFormat=5;
8151 break;
8152
8153 case 'L': //"&LBM"
8154 SnapshotFormat=6;
8155 break;
8156 }
8157 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8158
8159 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8160 return D_O_K;
8161 }
8162
8163
8164 42 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8165 {
8166 PALETTE tmp;
8167
8168
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 42 times.
10794 for(int32_t i=0; i<256; i++)
8169 {
8170 10752 tmp[i].r=r;
8171 10752 tmp[i].g=g;
8172 10752 tmp[i].b=b;
8173 10752 }
8174
8175 42 fade_interpolate(src,tmp,dest,pos,from,to);
8176 42 }
8177
8178 42 void system_pal()
8179 {
8180 42 is_sys_pal = true;
8181 static PALETTE pal;
8182 42 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8183
8184 // set up the grayscale palette
8185
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 42 times.
2730 for(int32_t i=128; i<192; i++)
8186 {
8187 2688 pal[i].r = i-128;
8188 2688 pal[i].g = i-128;
8189 2688 pal[i].b = i-128;
8190 2688 }
8191 42 load_colorset(gui_colorset, pal);
8192
8193 42 color_layer(pal, pal, 24,16,16, 28, 128,191);
8194
8195
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 42 times.
5418 for(int32_t i=0; i<256; i+=2)
8196 {
8197 5376 int32_t v = (i>>3)+2;
8198 5376 int32_t c = (i>>3)+192;
8199 5376 pal[c] = _RGB(v,v,v+(v>>1));
8200 /*
8201 if(i<240)
8202 {
8203 _allegro_hline(tmp_scr,0,i,319,c);
8204 _allegro_hline(tmp_scr,0,i+1,319,c);
8205 }
8206 */
8207 5376 }
8208
8209 // draw the vertical screen gradient
8210
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 42 times.
10122 for(int32_t i=0; i<240; ++i)
8211 {
8212 10080 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8213 10080 }
8214
8215 /*
8216 palrstart= 10*63/255; palrend=166*63/255;
8217 palgstart= 36*63/255; palgend=202*63/255;
8218 palbstart=106*63/255; palbend=240*63/255;
8219 paldivs=32;
8220 for(int32_t i=0; i<paldivs; i++)
8221 {
8222 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8223 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8224 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8225 }
8226 */
8227 42 BITMAP *panorama = create_bitmap_ex(8,256,224);
8228 int32_t ts_height, ts_start;
8229
8230
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8231 {
8232 clear_to_color(panorama,0);
8233 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8234 ts_height=224-passive_subscreen_height;
8235 ts_start=28;
8236 }
8237 else
8238 {
8239 42 blit(framebuf,panorama,0,0,0,0,256,224);
8240 42 ts_height=224;
8241 42 ts_start=0;
8242 }
8243
8244 // gray scale the current frame
8245
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 42 times.
9450 for(int32_t y=0; y<ts_height; y++)
8246 {
8247
2/2
✓ Branch 0 taken 2408448 times.
✓ Branch 1 taken 9408 times.
2417856 for(int32_t x=0; x<256; x++)
8248 {
8249 2408448 int32_t c = panorama->line[y+ts_start][x];
8250
2/2
✓ Branch 0 taken 2402558 times.
✓ Branch 1 taken 5890 times.
2408448 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8251 2408448 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8252 2408448 }
8253 9408 }
8254
8255 42 destroy_bitmap(panorama);
8256
8257 // display everything
8258 42 vsync();
8259 42 hw_palette = &pal;
8260 42 update_hw_pal = true;
8261
8262 // sys_pal = pal;
8263 42 memcpy(sys_pal,pal,sizeof(pal));
8264 42 }
8265
8266 void system_pal2()
8267 {
8268 is_sys_pal = true;
8269 static PALETTE RAMpal2;
8270 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8271
8272 /* Windows 2000 colors
8273 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8274 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8275 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8276 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8277 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8278 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8279 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8280 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8281
8282 byte palrstart= 10*63/255, palrend=166*63/255,
8283 palgstart= 36*63/255, palgend=202*63/255,
8284 palbstart=106*63/255, palbend=240*63/255,
8285 paldivs=7;
8286 for(int32_t i=0; i<paldivs; i++)
8287 {
8288 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8289 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8290 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8291 }
8292 */
8293
8294 /* Windows 98 colors
8295 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8296 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8297 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8298 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8299 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8300 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8301 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8302 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8303
8304 byte palrstart= 0*63/255, palrend=166*63/255,
8305 palgstart= 0*63/255, palgend=202*63/255,
8306 palbstart=128*63/255, palbend=240*63/255,
8307 paldivs=7;
8308 for(int32_t i=0; i<paldivs; i++)
8309 {
8310 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8311 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8312 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8313 }
8314 */
8315
8316 /* Windows 99 colors
8317 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8318 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8319 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8320 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8321 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8322 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8323 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8324 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8325 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8326
8327 byte palrstart= 0*63/255, palrend=166*63/255,
8328 palgstart= 0*63/255, palgend=202*63/255,
8329
8330 palbstart=128*63/255, palbend=240*63/255,
8331 paldivs=6;
8332 for(int32_t i=0; i<paldivs; i++)
8333 {
8334 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8335 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8336 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8337 }
8338 */
8339
8340
8341
8342 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8343 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8344 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8345 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8346 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8347 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8348 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8349 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8350 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8351
8352 byte palrstart= 0*63/255, palrend=166*63/255,
8353 palgstart= 0*63/255, palgend=202*63/255,
8354 palbstart=128*63/255, palbend=240*63/255,
8355 paldivs=6;
8356
8357 for(int32_t i=0; i<paldivs; i++)
8358 {
8359 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8360 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8361 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8362 }
8363
8364 gui_bg_color=jwin_pal[jcBOX];
8365 gui_fg_color=jwin_pal[jcBOXFG];
8366
8367 jwin_set_colors(jwin_pal);
8368
8369
8370 // set up the new palette
8371 for(int32_t i=128; i<192; i++)
8372 {
8373 RAMpal2[i].r = i-128;
8374 RAMpal2[i].g = i-128;
8375 RAMpal2[i].b = i-128;
8376 }
8377
8378 /*
8379 for(int32_t i=0; i<64; i++)
8380 {
8381 RAMpal2[128+i] = _RGB(i,i,i)1));
8382 }
8383 */
8384
8385 /*
8386
8387 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8388 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8389 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8390 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8391 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8392 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8393 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8394
8395 gui_fg_color=vc(14);
8396 gui_bg_color=vc(1);
8397
8398 jwin_set_colors(jwin_pal);
8399 */
8400
8401 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8402
8403 // set up the colors for the vertical screen gradient
8404 for(int32_t i=0; i<256; i+=2)
8405 {
8406 int32_t v = (i>>3)+2;
8407 int32_t c = (i>>3)+192;
8408 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8409
8410 /*
8411 if(i<240)
8412 {
8413 _allegro_hline(tmp_scr,0,i,319,c);
8414 _allegro_hline(tmp_scr,0,i+1,319,c);
8415 }
8416 */
8417 }
8418
8419 // hw_palette = &RAMpal;
8420 // update_hw_pal = true;
8421
8422 for(int32_t i=0; i<240; ++i)
8423 {
8424 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8425 }
8426
8427 /*
8428 byte palrstart= 10*63/255, palrend=166*63/255,
8429 palgstart= 36*63/255, palgend=202*63/255,
8430 palbstart=106*63/255, palbend=240*63/255,
8431 paldivs=32;
8432 for(int32_t i=0; i<paldivs; i++)
8433 {
8434 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8435 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8436 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8437 }
8438 */
8439 BITMAP *panorama = create_bitmap_ex(8,256,224);
8440 int32_t ts_height, ts_start;
8441
8442 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8443 {
8444 clear_to_color(panorama,0);
8445 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8446 ts_height=224-passive_subscreen_height;
8447 ts_start=28;
8448 }
8449 else
8450 {
8451 blit(framebuf,panorama,0,0,0,0,256,224);
8452 ts_height=224;
8453 ts_start=0;
8454 }
8455
8456 // gray scale the current frame
8457 for(int32_t y=0; y<ts_height; y++)
8458 {
8459 for(int32_t x=0; x<256; x++)
8460 {
8461 int32_t c = panorama->line[y+ts_start][x];
8462 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8463 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8464 }
8465 }
8466
8467 destroy_bitmap(panorama);
8468
8469 // display everything
8470 vsync();
8471 hw_palette = &RAMpal2;
8472 update_hw_pal = true;
8473
8474 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8475
8476 // sys_pal = pal;
8477 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8478 }
8479
8480 static uint32_t entered_sys_pal = 0;
8481 14 void enter_sys_pal()
8482 {
8483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8484 {
8485 if(entered_sys_pal)
8486 ++entered_sys_pal;
8487 return;
8488 }
8489 14 system_pal();
8490 14 ++entered_sys_pal;
8491 14 }
8492 14 void exit_sys_pal()
8493 {
8494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8495 {
8496
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8497 {
8498 14 game_pal();
8499 14 }
8500 14 }
8501 14 }
8502
8503 void switch_out_callback()
8504 {
8505 if (pause_in_background)
8506 {
8507 callback_switchin = 3;
8508 return;
8509 }
8510
8511 #ifdef _WIN32
8512 if(midi_patch_fix==0 || currmidi==-1)
8513 return;
8514
8515
8516 paused_midi_pos = midi_pos;
8517 zc_stop_midi();
8518 midi_paused=true;
8519 midi_suspended = midissuspHALTED;
8520 #endif
8521 }
8522
8523 void switch_in_callback()
8524 {
8525 if(pause_in_background)
8526 {
8527 return;
8528 }
8529
8530 #ifdef _WIN32
8531 if(midi_patch_fix==0 || currmidi==-1)
8532 return;
8533
8534 else
8535 {
8536 callback_switchin = 1;
8537 midi_suspended = midissuspRESUME;
8538 }
8539 #endif
8540 }
8541
8542 218 void game_pal()
8543 {
8544 218 is_sys_pal = false;
8545 218 entered_sys_pal = 0;
8546 218 clear_to_color(screen,BLACK);
8547 218 hw_palette = &RAMpal;
8548 218 update_hw_pal = true;
8549 218 }
8550
8551 static char bar_str[] = "";
8552
8553 14 void music_pause()
8554 {
8555 //al_pause_duh(tmplayer);
8556 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8557 14 zc_midi_pause();
8558 14 midi_paused=true;
8559 14 }
8560
8561 void music_resume()
8562 {
8563 //al_resume_duh(tmplayer);
8564 zcmusic_pause(zcmusic, ZCM_RESUME);
8565 zc_midi_resume();
8566 midi_paused=false;
8567 }
8568
8569 4188 void music_stop()
8570 {
8571 //al_stop_duh(tmplayer);
8572 //unload_duh(tmusic);
8573 //tmusic=NULL;
8574 //tmplayer=NULL;
8575 4188 zcmusic_stop(zcmusic);
8576 4188 zcmusic_unload_file(zcmusic);
8577 4188 zc_stop_midi();
8578 4188 midi_paused=false;
8579 4188 currmidi=-1;
8580 4188 }
8581
8582 void System()
8583 {
8584 mouse_down=gui_mouse_b();
8585 music_pause();
8586 pause_all_sfx();
8587 MenuOpen = true;
8588 system_pal();
8589 // FONT *oldfont=font;
8590 // font=tfont;
8591
8592 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8593 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8594
8595 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8596 #if DEVLEVEL > 1
8597 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8598 #endif
8599 game_menu[3].flags =
8600 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8601 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8602 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8603 clear_keybuf();
8604 show_mouse(screen);
8605
8606 DIALOG_PLAYER *p;
8607
8608 clear_bitmap(menu_bmp);
8609 oldscreen = screen;
8610 screen = menu_bmp;
8611
8612 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8613 {
8614 p = init_dialog(system_dlg2,-1);
8615 }
8616 else
8617 {
8618 p = init_dialog(system_dlg,-1);
8619 }
8620
8621 // drop the menu on startup if menu button pressed
8622 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8623 simulate_keypress(KEY_G << 8);
8624
8625 do
8626 {
8627 if(close_button_quit)
8628 {
8629 close_button_quit = false;
8630 f_Quit(qEXIT);
8631 if(Quit) break;
8632 }
8633 rest(17);
8634
8635 if(mouse_down && !gui_mouse_b())
8636 mouse_down=0;
8637
8638 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8639 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8640 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8641
8642 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8643 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8644 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8645 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8646 settings_menu[8].flags = NESquit?D_SELECTED:0;
8647 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8648 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8649 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8650 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8651 settings_menu[13].flags = volkeys?D_SELECTED:0;
8652 //Epilepsy Prevention
8653 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8654
8655 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8656 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8657 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8658
8659 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8660 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8661 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8662
8663 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8664 cheat_menu[0].flags = 0;
8665 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8666 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8667 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8668 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8669 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8670 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8671 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8672 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8673 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8674
8675 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8676 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8677 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8678 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8679 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8680 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8681 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8682 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8683 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8684 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8685 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8686 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8687 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8688 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8689 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8690
8691 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8692 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8693
8694 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8695 (char *)"Disable recording new saves" :
8696 (char *)"Enable recording new saves";
8697 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8698 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8699 (char *)"Stop recording" :
8700 (char *)"Stop replaying";
8701 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8702 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8703 (char *)"Disable snapshot all frames" :
8704 (char *)"Enable snapshot all frames";
8705
8706 reset_snapshot_format_menu();
8707 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8708
8709 if(debug_enabled)
8710 {
8711 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8712 }
8713
8714 if(gui_mouse_b() && !mouse_down)
8715 break;
8716
8717 // press menu to drop the menu
8718 if(rMbtn())
8719 simulate_keypress(KEY_G << 8);
8720
8721 if(input_idle(true) > after_time())
8722 // run Screeen Saver
8723 {
8724 // Screen saver enabled for now.
8725 clear_keybuf();
8726 scare_mouse();
8727 Matrix(ss_speed, ss_density, 0);
8728 system_pal();
8729 unscare_mouse();
8730 broadcast_dialog_message(MSG_DRAW, 0);
8731 }
8732
8733 update_hw_screen();
8734 }
8735 while(update_dialog(p));
8736
8737 screen = oldscreen;
8738
8739 // font=oldfont;
8740 mouse_down=gui_mouse_b();
8741 shutdown_dialog(p);
8742 show_mouse(NULL);
8743 MenuOpen = false;
8744 if(Quit)
8745 {
8746 kill_sfx();
8747 music_stop();
8748 update_hw_screen();
8749 }
8750 else
8751 {
8752 game_pal();
8753 music_resume();
8754 resume_all_sfx();
8755
8756 if(rc)
8757 ringcolor(false);
8758 }
8759
8760 eat_buttons();
8761
8762 rc=false;
8763 clear_keybuf();
8764 // text_mode(0);
8765 }
8766
8767 28 void fix_dialogs()
8768 {
8769 28 jwin_center_dialog(about_dlg);
8770 28 jwin_center_dialog(gamepad_dlg);
8771 28 jwin_center_dialog(credits_dlg);
8772 28 jwin_center_dialog(gamemode_dlg);
8773 28 jwin_center_dialog(getnum_dlg);
8774 28 jwin_center_dialog(goto_dlg);
8775 28 jwin_center_dialog(keyboard_control_dlg);
8776 28 jwin_center_dialog(midi_dlg);
8777 28 jwin_center_dialog(quest_dlg);
8778 28 jwin_center_dialog(scrsaver_dlg);
8779 28 jwin_center_dialog(sound_dlg);
8780 28 jwin_center_dialog(triforce_dlg);
8781
8782 // digi_dp[1] += scrx;
8783 // digi_dp[2] += scry;
8784 // midi_dp[1] += scrx;
8785 // midi_dp[2] += scry;
8786 // pan_dp[1] += scrx;
8787 // pan_dp[2] += scry;
8788 // emus_dp[1] += scrx;
8789 // emus_dp[2] += scry;
8790 // buf_dp[1] += scrx;
8791 // buf_dp[2] += scry;
8792 // sfx_dp[1] += scrx;
8793 // sfx_dp[2] += scry;
8794 28 }
8795
8796 /*****************************/
8797 /**** Custom Sound System ****/
8798 /*****************************/
8799
8800 1610 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8801 {
8802
3/4
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 1610 times.
✗ Branch 3 not taken.
1610 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8803 }
8804
8805 // Run an NSF, or a MIDI if the NSF is missing somehow.
8806 74 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8807 {
8808 74 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8809
8810 // Found it
8811
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 35 times.
74 if(newzcmusic!=NULL)
8812 {
8813 39 zcmusic_stop(zcmusic);
8814 39 zcmusic_unload_file(zcmusic);
8815 39 zc_stop_midi();
8816
8817 39 zcmusic=newzcmusic;
8818 39 zcmusic_play(zcmusic, emusic_volume);
8819
8820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(track>0)
8821 39 zcmusic_change_track(zcmusic,track);
8822
8823 39 return true;
8824 }
8825
8826 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8827
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8828 jukebox(midi);
8829
8830 35 return false;
8831 74 }
8832
8833 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8834 {
8835 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8836 // Found it
8837 if(newzcmusic!=NULL)
8838 {
8839 zcmusic_stop(zcmusic);
8840 zcmusic_unload_file(zcmusic);
8841 zc_stop_midi();
8842
8843 zcmusic=newzcmusic;
8844 zcmusic_play(zcmusic, emusic_volume);
8845
8846 if(track>0)
8847 zcmusic_change_track(zcmusic,track);
8848
8849 return true;
8850 }
8851
8852 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8853 else if(midi>-1000)
8854 jukebox(midi);
8855
8856 return false;
8857 }
8858
8859 int32_t get_zcmusicpos()
8860 {
8861 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8862 return debugtracething;
8863 return 0;
8864 }
8865
8866 void set_zcmusicpos(int32_t position)
8867 {
8868 zcmusic_set_curpos(zcmusic, position);
8869 }
8870
8871 void set_zcmusicspeed(int32_t speed)
8872 {
8873 int32_t newspeed = vbound(speed, 0, 10000);
8874 zcmusic_set_speed(zcmusic, newspeed);
8875 }
8876
8877 791 void jukebox(int32_t index,int32_t loop)
8878 {
8879 791 music_stop();
8880
8881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 791 times.
791 if(index<0) index=MAXMIDIS-1;
8882
8883
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(index>=MAXMIDIS) index=0;
8884
8885 791 music_stop();
8886
8887 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8888 // stuck notes when a song stops. This fixes it.
8889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 791 times.
791 if(strcmp(midi_driver->name, "DIGMID")==0)
8890 zc_set_volume(0, 0);
8891
8892 791 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8893 791 zc_play_midi((MIDI*)tunes[index].data,loop);
8894
8895
2/2
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 209 times.
791 if(tunes[index].start>0)
8896 209 zc_midi_seek(tunes[index].start);
8897
8898 791 midi_loop_start = tunes[index].loop_start;
8899 791 midi_loop_end = tunes[index].loop_end;
8900
8901 791 currmidi=index;
8902 791 master_volume(digi_volume,midi_volume);
8903 791 midi_paused=false;
8904 791 }
8905
8906 5392 void jukebox(int32_t index)
8907 {
8908
1/2
✓ Branch 0 taken 5392 times.
✗ Branch 1 not taken.
5392 if(index<0) index=MAXMIDIS-1;
8909
8910
1/2
✓ Branch 0 taken 5392 times.
✗ Branch 1 not taken.
5392 if(index>=MAXMIDIS) index=0;
8911
8912 // do nothing if it's already playing
8913
3/4
✓ Branch 0 taken 4601 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 4601 times.
✗ Branch 3 not taken.
5392 if(index==currmidi && midi_pos>=0)
8914 {
8915 4601 midi_paused=false;
8916 4601 return;
8917 }
8918
8919 791 jukebox(index,tunes[index].loop);
8920 5392 }
8921
8922 6631 void play_DmapMusic()
8923 {
8924 static char tfile[2048];
8925 static int32_t ttrack=0;
8926 6631 bool domidi=false;
8927
8928
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 5301 times.
6631 if(DMaps[currdmap].tmusic[0]!=0)
8929 {
8930
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8931
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8932
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8933 {
8934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8935 {
8936 zcmusic_stop(zcmusic);
8937 zcmusic_unload_file(zcmusic);
8938 zcmusic = NULL;
8939 }
8940
8941 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8942
8943
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8944 {
8945 86 zc_stop_midi();
8946 86 strcpy(tfile,DMaps[currdmap].tmusic);
8947 86 zcmusic_play(zcmusic, emusic_volume);
8948 86 int32_t temptracks=0;
8949 86 temptracks=zcmusic_get_tracks(zcmusic);
8950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8951 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8952 86 zcmusic_change_track(zcmusic,ttrack);
8953 86 }
8954 else
8955 {
8956 859 tfile[0] = 0;
8957 859 domidi=true;
8958 }
8959 945 }
8960 1330 }
8961 else
8962 {
8963 5301 domidi=true;
8964 }
8965
8966
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 6160 times.
6631 if(domidi)
8967 {
8968 6160 int32_t m=DMaps[currdmap].midi;
8969
8970
3/4
✓ Branch 0 taken 6045 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
6160 switch(m)
8971 {
8972 case 1:
8973 105 jukebox(ZC_MIDI_OVERWORLD);
8974 105 break;
8975
8976 case 2:
8977 10 jukebox(ZC_MIDI_DUNGEON);
8978 10 break;
8979
8980 case 3:
8981 jukebox(ZC_MIDI_LEVEL9);
8982 break;
8983
8984 default:
8985
3/4
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5136 times.
6045 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8986 5136 jukebox(m+MIDIOFFSET_DMAP);
8987 else
8988 909 music_stop();
8989 6045 }
8990 6160 }
8991 6631 }
8992
8993 6668 void playLevelMusic()
8994 {
8995 6668 int32_t m=tmpscr->screen_midi;
8996
8997
3/6
✓ Branch 0 taken 6615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
6668 switch(m)
8998 {
8999 case -2:
9000 12 music_stop();
9001 12 break;
9002
9003 case -1:
9004 6615 play_DmapMusic();
9005 6615 break;
9006
9007 case 1:
9008 jukebox(ZC_MIDI_OVERWORLD);
9009 break;
9010
9011 case 2:
9012 jukebox(ZC_MIDI_DUNGEON);
9013 break;
9014
9015 case 3:
9016 jukebox(ZC_MIDI_LEVEL9);
9017 break;
9018
9019 default:
9020
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9021 41 jukebox(m+MIDIOFFSET_MAPSCR);
9022 else
9023 music_stop();
9024 41 }
9025 6668 }
9026
9027 819 void master_volume(int32_t dv,int32_t mv)
9028 {
9029
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 819 times.
✓ Branch 2 taken 819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 819 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 819 times.
✗ Branch 7 not taken.
819 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9030
9031
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 819 times.
✓ Branch 2 taken 819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 819 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 819 times.
✗ Branch 7 not taken.
819 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9032
9033
6/6
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 818 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 789 times.
✓ Branch 5 taken 29 times.
819 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9034 819 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9035 819 }
9036
9037 /*****************/
9038 /***** SFX *****/
9039 /*****************/
9040
9041 // array of voices, one for each sfx sample in the data file
9042 // 0+ = voice #
9043 // -1 = voice not allocated
9044 28 void Z_init_sound()
9045 {
9046
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 28 times.
7196 for(int32_t i=0; i<WAV_COUNT; i++)
9047 7168 sfx_voice[i]=-1;
9048
9049
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 28 times.
224 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9050 196 tunes[i].data = (MIDI*)mididata[i].dat;
9051
9052
2/2
✓ Branch 0 taken 7056 times.
✓ Branch 1 taken 28 times.
7084 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9053 7056 tunes[ZC_MIDI_COUNT+j].data=NULL;
9054
9055 28 master_volume(digi_volume,midi_volume);
9056 28 }
9057
9058 // returns number of voices currently allocated
9059 int32_t sfx_count()
9060 {
9061 int32_t c=0;
9062
9063 for(int32_t i=0; i<WAV_COUNT; i++)
9064 if(sfx_voice[i]!=-1)
9065 ++c;
9066
9067 return c;
9068 }
9069
9070 // clean up finished samples
9071 4794176 void sfx_cleanup()
9072 {
9073
2/2
✓ Branch 0 taken 1227309056 times.
✓ Branch 1 taken 4794176 times.
1232103232 for(int32_t i=0; i<WAV_COUNT; i++)
9074
3/4
✓ Branch 0 taken 450467 times.
✓ Branch 1 taken 1226858589 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 450467 times.
1227759523 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9075 {
9076 450467 deallocate_voice(sfx_voice[i]);
9077 450467 sfx_voice[i]=-1;
9078 450467 }
9079 4794176 }
9080
9081 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9082 // if a voice is already allocated (and/or playing), then it just returns true
9083 // Returns true: voice is allocated
9084 // false: unsuccessful
9085 683368 bool sfx_init(int32_t index)
9086 {
9087 // check index
9088
3/4
✓ Branch 0 taken 502869 times.
✓ Branch 1 taken 180499 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 502869 times.
683368 if(index<=0 || index>=WAV_COUNT)
9089 180499 return false;
9090
9091
2/2
✓ Branch 0 taken 52382 times.
✓ Branch 1 taken 450487 times.
502869 if(sfx_voice[index]==-1)
9092 {
9093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450487 times.
450487 if(sfxdat)
9094 {
9095 if(index<Z35)
9096 {
9097 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9098 }
9099 else
9100 {
9101 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9102 }
9103 }
9104 else
9105 {
9106 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9107 }
9108
9109 450487 voice_set_volume(sfx_voice[index], sfx_volume);
9110 450487 }
9111
9112 502869 return sfx_voice[index] != -1;
9113 683368 }
9114
9115 // plays an sfx sample
9116 587877 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9117 {
9118
2/2
✓ Branch 0 taken 440900 times.
✓ Branch 1 taken 146977 times.
587877 if(!sfx_init(index))
9119 146977 return;
9120
9121 440900 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9122 440900 voice_set_pan(sfx_voice[index],pan);
9123
9124 440900 int32_t pos = voice_get_position(sfx_voice[index]);
9125
9126
2/2
✓ Branch 0 taken 261051 times.
✓ Branch 1 taken 179849 times.
440900 if(restart) voice_set_position(sfx_voice[index],0);
9127
9128
1/2
✓ Branch 0 taken 440900 times.
✗ Branch 1 not taken.
440900 if(pos<=0)
9129 440900 voice_start(sfx_voice[index]);
9130 587877 }
9131
9132 // true if sfx is allocated
9133 21672 bool sfx_allocated(int32_t index)
9134 {
9135
2/4
✓ Branch 0 taken 21672 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21672 times.
21672 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9136 }
9137
9138 // start it (in loop mode) if it's not already playing,
9139 // otherwise adjust it to play in loop mode -DD
9140 95491 void cont_sfx(int32_t index)
9141 {
9142
2/2
✓ Branch 0 taken 33522 times.
✓ Branch 1 taken 61969 times.
95491 if(!sfx_init(index))
9143 {
9144 33522 return;
9145 }
9146
9147
1/2
✓ Branch 0 taken 61969 times.
✗ Branch 1 not taken.
61969 if(voice_get_position(sfx_voice[index])<=0)
9148 {
9149 61969 voice_set_position(sfx_voice[index],0);
9150 61969 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9151 61969 voice_start(sfx_voice[index]);
9152 61969 }
9153 else
9154 {
9155 adjust_sfx(index, 128, true);
9156 }
9157 95491 }
9158
9159 // adjust parameters while playing
9160 2756 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9161 {
9162
5/6
✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 1166 times.
✓ Branch 2 taken 1590 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 1578 times.
2756 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9163 2744 return;
9164
9165 12 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9166 12 voice_set_pan(sfx_voice[index],pan);
9167 2756 }
9168
9169 // pauses a voice
9170 1037 void pause_sfx(int32_t index)
9171 {
9172
3/6
✓ Branch 0 taken 1037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1037 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1037 times.
1037 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9173 voice_stop(sfx_voice[index]);
9174 1037 }
9175
9176 // resumes a voice
9177 484 void resume_sfx(int32_t index)
9178 {
9179
3/6
✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 484 times.
484 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9180 voice_start(sfx_voice[index]);
9181 484 }
9182
9183 // pauses all active voices
9184 113 void pause_all_sfx()
9185 {
9186
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<WAV_COUNT; i++)
9187
2/2
✓ Branch 0 taken 28926 times.
✓ Branch 1 taken 2 times.
28930 if(sfx_voice[i]!=-1)
9188 2 voice_stop(sfx_voice[i]);
9189 113 }
9190
9191 // resumes all paused voices
9192 99 void resume_all_sfx()
9193 {
9194
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<WAV_COUNT; i++)
9195
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 if(sfx_voice[i]!=-1)
9196 voice_start(sfx_voice[i]);
9197 99 }
9198
9199 // stops an sfx and deallocates the voice
9200 3803780 void stop_sfx(int32_t index)
9201 {
9202
3/4
✓ Branch 0 taken 3712139 times.
✓ Branch 1 taken 91641 times.
✓ Branch 2 taken 3712139 times.
✗ Branch 3 not taken.
3803780 if(index<=0 || index>=WAV_COUNT)
9203 91641 return;
9204
9205
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3712126 times.
3712139 if(sfx_voice[index]!=-1)
9206 {
9207 13 deallocate_voice(sfx_voice[index]);
9208 13 sfx_voice[index]=-1;
9209 13 }
9210 3803780 }
9211
9212 // Stops SFX played by Hero's item of the given family
9213 131093 void stop_item_sfx(int32_t family)
9214 {
9215 131093 int32_t id=current_item_id(family);
9216
9217
2/2
✓ Branch 0 taken 130827 times.
✓ Branch 1 taken 266 times.
131093 if(id<0)
9218 130827 return;
9219
9220 266 stop_sfx(itemsbuf[id].usesound);
9221 131093 }
9222
9223 1400 void kill_sfx()
9224 {
9225
2/2
✓ Branch 0 taken 358400 times.
✓ Branch 1 taken 1400 times.
359800 for(int32_t i=0; i<WAV_COUNT; i++)
9226
2/2
✓ Branch 0 taken 358393 times.
✓ Branch 1 taken 7 times.
358407 if(sfx_voice[i]!=-1)
9227 {
9228 7 deallocate_voice(sfx_voice[i]);
9229 7 sfx_voice[i]=-1;
9230 7 }
9231 1400 }
9232
9233 372465 int32_t pan(int32_t x)
9234 {
9235
1/4
✓ Branch 0 taken 372465 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
372465 switch(pan_style)
9236 {
9237 case 0:
9238 return 128;
9239
9240 case 1:
9241 372465 return vbound((x>>1)+68,0,255);
9242
9243 case 2:
9244 return vbound(((x*3)>>2)+36,0,255);
9245 }
9246
9247 return vbound(x,0,255);
9248 372465 }
9249
9250 /*******************************/
9251 /******* Input Handlers ********/
9252 /*******************************/
9253
9254 11390682 bool joybtn(int32_t b)
9255 {
9256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11390682 times.
11390682 if(b == 0)
9257 return false;
9258
9259 11390682 return joy[joystick_index].button[b-1].b !=0;
9260 11390682 }
9261
9262 const char* joybtn_name(int32_t b)
9263 {
9264 if(b == 0)
9265 return "";
9266
9267 return joy[joystick_index].button[b-1].name;
9268 }
9269
9270 int32_t next_press_key()
9271 {
9272 return readkey()>>8;
9273 }
9274
9275 int32_t next_press_btn()
9276 {
9277 clear_keybuf();
9278 /*bool b[joy[joystick_index].num_buttons+1];
9279
9280 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9281 b[i]=joybtn(i);*/
9282
9283 //first, we need to wait until they're pressing no buttons
9284 for(;;)
9285 {
9286 if(keypressed())
9287 {
9288 switch(readkey()>>8)
9289 {
9290 case KEY_ESC:
9291 return -1;
9292
9293 case KEY_SPACE:
9294 return 0;
9295 }
9296 }
9297
9298 poll_joystick();
9299 bool done = true;
9300
9301 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9302 {
9303 if(joybtn(i)) done = false;
9304 }
9305
9306 if(done) break;
9307 rest(1);
9308 }
9309
9310 //now, we need to wait for them to press any button
9311 for(;;)
9312 {
9313 if(keypressed())
9314 {
9315 switch(readkey()>>8)
9316 {
9317 case KEY_ESC:
9318 return -1;
9319
9320 case KEY_SPACE:
9321 return 0;
9322 }
9323 }
9324
9325 poll_joystick();
9326
9327 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9328 {
9329 if(joybtn(i)) return i;
9330 }
9331 rest(1);
9332 }
9333 }
9334
9335 98412891 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9336 {
9337
2/2
✓ Branch 0 taken 94798656 times.
✓ Branch 1 taken 3614235 times.
98412891 bool ret = btn && !flag;
9338
2/2
✓ Branch 0 taken 91493195 times.
✓ Branch 1 taken 6919696 times.
98412891 flag = rawbtn ? *rawbtn : btn;
9339
9340 98412891 return ret;
9341 }
9342 10039 static bool rButtonPeek(bool btn, bool flag)
9343 {
9344
2/2
✓ Branch 0 taken 9794 times.
✓ Branch 1 taken 245 times.
10039 if(!btn)
9345 {
9346 9794 return false;
9347 }
9348
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 193 times.
245 else if(!flag)
9349 {
9350 52 return true;
9351 }
9352
9353 193 return false;
9354 10039 }
9355
9356 // Updated only by keyboard/gamepad.
9357 // If in replay mode, this is set directly by the replay system.
9358 // This should never be read from directly - use control_state instead.
9359 bool raw_control_state[ZC_CONTROL_STATES];
9360
9361 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9362 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9363 // lasts until the next call to load_control_state.
9364 bool control_state[ZC_CONTROL_STATES];
9365 bool disable_control[ZC_CONTROL_STATES];
9366 bool drunk_toggle_state[11];
9367 bool disabledKeys[127];
9368 bool KeyInput[127];
9369 bool KeyPress[127];
9370
9371 bool key_current_frame[127];
9372 bool key_previous_frame[127];
9373
9374 static bool key_system[127];
9375 static bool key_system_previous[127];
9376 static bool key_system_press[127];
9377
9378 bool button_press[ZC_CONTROL_STATES];
9379 bool button_hold[ZC_CONTROL_STATES];
9380
9381 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9382 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9383 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9384 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9385 #define STICK_PRECISION 56 //define your own sensitivity
9386
9387 3988770 void load_control_state()
9388 {
9389 3988770 load_control_called_this_frame = true;
9390
9391
3/4
✓ Branch 0 taken 1117569 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1117569 times.
3988770 if (replay_get_version() >= 8 && replay_get_version() < 11)
9392 {
9393
2/2
✓ Branch 0 taken 20116242 times.
✓ Branch 1 taken 1117569 times.
21233811 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9394 20116242 down_control_states[i] = raw_control_state[i];
9395 1117569 }
9396
9397
1/2
✓ Branch 0 taken 3988770 times.
✗ Branch 1 not taken.
3988770 if (!replay_is_replaying())
9398 {
9399 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9400 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9401 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9402 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9403 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9404 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9405 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9406 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9407 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9408 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9409 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9410 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9411 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9412 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9413
9414 if(num_joysticks != 0)
9415 {
9416 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9417 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9418 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9419 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9420 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9421 }
9422 else
9423 {
9424 raw_control_state[14] = false;
9425 raw_control_state[15] = false;
9426 raw_control_state[16] = false;
9427 raw_control_state[17] = false;
9428 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9429 }
9430 }
9431
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3988767 times.
3988770 if (replay_is_active())
9432 {
9433
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 2973552 times.
3988767 if (replay_get_version() < 3)
9434 1015215 replay_poll();
9435
3/4
✓ Branch 0 taken 2973552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1212177 times.
✓ Branch 3 taken 1761375 times.
2973552 else if (replay_is_replaying() && replay_get_version() < 6)
9436 1761375 replay_peek_input();
9437
4/6
✓ Branch 0 taken 1212177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1117569 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1117569 times.
1212177 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9438 1117569 replay_peek_input();
9439
2/2
✓ Branch 0 taken 2871301 times.
✓ Branch 1 taken 1117466 times.
3988767 if (replay_get_version() == 8)
9440 1117466 update_keys();
9441 3988767 }
9442
9443 // Some test replay files were made before a serious input bug was fixed, so instead
9444 // of re-doing them or tossing them out, just check for that zplay version.
9445
3/4
✓ Branch 0 taken 3988764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 3866864 times.
3988770 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9446
2/2
✓ Branch 0 taken 71797752 times.
✓ Branch 1 taken 3988764 times.
75786516 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9447 {
9448 71797752 control_state[i] = raw_control_state[i];
9449
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 22310442 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
71797752 if (botched_input && !control_state[i])
9450 47077142 down_control_states[i] = false;
9451 71797752 }
9452
9453 3988764 button_press[0]=rButton(control_state[0],button_hold[0]);
9454 3988764 button_press[1]=rButton(control_state[1],button_hold[1]);
9455 3988764 button_press[2]=rButton(control_state[2],button_hold[2]);
9456 3988764 button_press[3]=rButton(control_state[3],button_hold[3]);
9457 3988764 button_press[4]=rButton(control_state[4],button_hold[4]);
9458 3988764 button_press[5]=rButton(control_state[5],button_hold[5]);
9459 3988764 button_press[6]=rButton(control_state[6],button_hold[6]);
9460 3988764 button_press[7]=rButton(control_state[7],button_hold[7]);
9461 3988764 button_press[8]=rButton(control_state[8],button_hold[8]);
9462 3988764 button_press[9]=rButton(control_state[9],button_hold[9]);
9463 3988764 button_press[10]=rButton(control_state[10],button_hold[10]);
9464 3988764 button_press[11]=rButton(control_state[11],button_hold[11]);
9465 3988764 button_press[12]=rButton(control_state[12],button_hold[12]);
9466 3988764 button_press[13]=rButton(control_state[13],button_hold[13]);
9467 3988764 button_press[14]=rButton(control_state[14],button_hold[14]);
9468 3988764 button_press[15]=rButton(control_state[15],button_hold[15]);
9469 3988764 button_press[16]=rButton(control_state[16],button_hold[16]);
9470 3988764 button_press[17]=rButton(control_state[17],button_hold[17]);
9471 3988764 }
9472
9473 // Returns true if any game key is pressed. This is needed because keypressed()
9474 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9475 20700760 bool zc_key_pressed()
9476 //may also need to use zc_getrawkey
9477 {
9478
7/10
✓ Branch 0 taken 16736822 times.
✓ Branch 1 taken 3963938 times.
✓ Branch 2 taken 3963938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3963938 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3371702 times.
✓ Branch 7 taken 3371702 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1110232 times.
21810992 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9479
4/6
✓ Branch 0 taken 3371702 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3371702 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2530856 times.
✓ Branch 5 taken 2530856 times.
3371702 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9480
4/6
✓ Branch 0 taken 2530856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2530856 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600167 times.
✓ Branch 5 taken 1600167 times.
2530856 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9481
4/6
✓ Branch 0 taken 1600167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600167 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1284025 times.
✓ Branch 5 taken 1284025 times.
1600167 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9482
1/2
✓ Branch 0 taken 1284025 times.
✗ Branch 1 not taken.
1284025 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9483
3/4
✓ Branch 0 taken 1193369 times.
✓ Branch 1 taken 90656 times.
✓ Branch 2 taken 1193369 times.
✗ Branch 3 not taken.
1284025 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9484
3/4
✓ Branch 0 taken 1129900 times.
✓ Branch 1 taken 63469 times.
✓ Branch 2 taken 1129900 times.
✗ Branch 3 not taken.
1193369 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9485
3/4
✓ Branch 0 taken 1119117 times.
✓ Branch 1 taken 10783 times.
✓ Branch 2 taken 1119117 times.
✗ Branch 3 not taken.
1129900 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9486
3/4
✓ Branch 0 taken 1111460 times.
✓ Branch 1 taken 7657 times.
✓ Branch 2 taken 1111460 times.
✗ Branch 3 not taken.
1119117 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9487
3/4
✓ Branch 0 taken 1111060 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 1111060 times.
✗ Branch 3 not taken.
1111460 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9488
3/4
✓ Branch 0 taken 1111017 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1111017 times.
✗ Branch 3 not taken.
1111060 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9489
3/4
✓ Branch 0 taken 1110251 times.
✓ Branch 1 taken 766 times.
✓ Branch 2 taken 1110251 times.
✗ Branch 3 not taken.
1111017 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9490
2/4
✓ Branch 0 taken 1110251 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1110251 times.
✗ Branch 3 not taken.
1110251 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9491
2/2
✓ Branch 0 taken 1110232 times.
✓ Branch 1 taken 19 times.
1110251 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9492 37164028 return true;
9493
9494 1110232 return false;
9495 4800616 }
9496
9497 79197036 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9498 {
9499 79197036 bool ret = false, drunkstate = false, rawret = false;
9500 79197036 bool* flag = &down_control_states[btn];
9501
2/7
✓ Branch 0 taken 74391456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 4805580 times.
79197036 switch(btn)
9502 {
9503 case btnF12:
9504 ret = zc_getkey(KEY_F12, ignoreDisable);
9505 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9506 eatEntirely = false;
9507 break;
9508 case btnF11:
9509 ret = zc_getkey(KEY_F11, ignoreDisable);
9510 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9511 eatEntirely = false;
9512 break;
9513 case btnF5:
9514 ret = zc_getkey(KEY_F5, ignoreDisable);
9515 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9516 eatEntirely = false;
9517 break;
9518 case btnQ:
9519 ret = zc_getkey(KEY_Q, ignoreDisable);
9520 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9521 eatEntirely = false;
9522 break;
9523 case btnI:
9524 ret = zc_getkey(KEY_I, ignoreDisable);
9525 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9526 eatEntirely = false;
9527 break;
9528 case btnM:
9529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4805580 times.
4805580 if(FFCore.kb_typing_mode) return false;
9530 4805580 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9531 4805580 eatEntirely = false;
9532 4805580 break;
9533 default: //control_state[] index
9534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74391456 times.
74391456 if(FFCore.kb_typing_mode) return false;
9535
5/6
✓ Branch 0 taken 74229094 times.
✓ Branch 1 taken 162362 times.
✓ Branch 2 taken 2164291 times.
✓ Branch 3 taken 72064803 times.
✓ Branch 4 taken 2164291 times.
✗ Branch 5 not taken.
74391456 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9536
2/2
✓ Branch 0 taken 4027290 times.
✓ Branch 1 taken 70364166 times.
74391456 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9537
4/4
✓ Branch 0 taken 66553487 times.
✓ Branch 1 taken 7837969 times.
✓ Branch 2 taken 1187 times.
✓ Branch 3 taken 7836782 times.
82229425 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9538 74391456 rawret = raw_control_state[btn];
9539 74391456 }
9540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79197036 times.
79197036 assert(flag);
9541
2/2
✓ Branch 0 taken 52571858 times.
✓ Branch 1 taken 26625178 times.
79197036 if(press)
9542 {
9543
2/2
✓ Branch 0 taken 10039 times.
✓ Branch 1 taken 26615139 times.
26625178 if(peek)
9544 10039 ret = rButtonPeek(ret, *flag);
9545
3/4
✓ Branch 0 taken 26615139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6919696 times.
✓ Branch 3 taken 19695443 times.
26615139 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9546 6919696 else ret = rButton(ret, *flag, &rawret);
9547 26625178 }
9548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79197036 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79197036 if(eatEntirely && ret) control_state[btn] = false;
9549
3/4
✓ Branch 0 taken 59778423 times.
✓ Branch 1 taken 19418613 times.
✓ Branch 2 taken 59778423 times.
✗ Branch 3 not taken.
79197036 if(drunk && drunkstate) ret = !ret;
9550 79197036 return ret;
9551 79197036 }
9552
9553 397790 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9554 {
9555 397790 byte ret = 0;
9556
2/2
✓ Branch 0 taken 385761 times.
✓ Branch 1 taken 12029 times.
397790 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9557
2/2
✓ Branch 0 taken 397228 times.
✓ Branch 1 taken 562 times.
397790 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9558
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9559
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9560
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9561
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9562
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9563
2/2
✓ Branch 0 taken 397353 times.
✓ Branch 1 taken 437 times.
397790 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9564 397790 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9565 }
9566
9567 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9568 {
9569 1114 return intbtn&vals;
9570 }
9571
9572 924476 bool Up()
9573 {
9574 924476 return getInput(btnUp);
9575 }
9576 52368 bool Down()
9577 {
9578 52368 return getInput(btnDown);
9579 }
9580 141640 bool Left()
9581 {
9582 141640 return getInput(btnLeft);
9583 }
9584 163230 bool Right()
9585 {
9586 163230 return getInput(btnRight);
9587 }
9588 42106 bool cAbtn()
9589 {
9590 42106 return getInput(btnA);
9591 }
9592 683862 bool cBbtn()
9593 {
9594 683862 return getInput(btnB);
9595 }
9596 bool cSbtn()
9597 {
9598 return getInput(btnS);
9599 }
9600 6440 bool cLbtn()
9601 {
9602 6440 return getInput(btnL);
9603 }
9604 6440 bool cRbtn()
9605 {
9606 6440 return getInput(btnR);
9607 }
9608 bool cPbtn()
9609 {
9610 return getInput(btnP);
9611 }
9612 bool cEx1btn()
9613 {
9614 return getInput(btnEx1);
9615 }
9616 bool cEx2btn()
9617 {
9618 return getInput(btnEx2);
9619 }
9620 bool cEx3btn()
9621 {
9622 return getInput(btnEx3);
9623 }
9624 bool cEx4btn()
9625 {
9626 return getInput(btnEx4);
9627 }
9628 bool AxisUp()
9629 {
9630 return getInput(btnAxisUp);
9631 }
9632 bool AxisDown()
9633 {
9634 return getInput(btnAxisDown);
9635 }
9636 bool AxisLeft()
9637 {
9638 return getInput(btnAxisLeft);
9639 }
9640 bool AxisRight()
9641 {
9642 return getInput(btnAxisRight);
9643 }
9644
9645 bool cMbtn()
9646 {
9647 return getInput(btnM);
9648 }
9649 bool cF12()
9650 {
9651 return getInput(btnF12);
9652 }
9653 bool cF11()
9654 {
9655 return getInput(btnF11);
9656 }
9657 bool cF5()
9658 {
9659 return getInput(btnF5);
9660 }
9661 bool cQ()
9662 {
9663 return getInput(btnQ);
9664 }
9665 bool cI()
9666 {
9667 return getInput(btnI);
9668 }
9669
9670 68750 bool rUp()
9671 {
9672 68750 return getInput(btnUp, true);
9673 }
9674 68692 bool rDown()
9675 {
9676 68692 return getInput(btnDown, true);
9677 }
9678 68646 bool rLeft()
9679 {
9680 68646 return getInput(btnLeft, true);
9681 }
9682 68210 bool rRight()
9683 {
9684 68210 return getInput(btnRight, true);
9685 }
9686 2367 bool rAbtn()
9687 {
9688 2367 return getInput(btnA, true);
9689 }
9690 69250 bool rBbtn()
9691 {
9692 69250 return getInput(btnB, true);
9693 }
9694 3851535 bool rSbtn()
9695 {
9696 3851535 return getInput(btnS, true);
9697 }
9698 4800616 bool rMbtn()
9699 {
9700 4800616 return getInput(btnM, true);
9701 }
9702 68032 bool rLbtn()
9703 {
9704 68032 return getInput(btnL, true);
9705 }
9706 68029 bool rRbtn()
9707 {
9708 68029 return getInput(btnR, true);
9709 }
9710 3788346 bool rPbtn()
9711 {
9712 3788346 return getInput(btnP, true);
9713 }
9714 bool rEx1btn()
9715 {
9716 return getInput(btnEx1, true);
9717 }
9718 bool rEx2btn()
9719 {
9720 return getInput(btnEx2, true);
9721 }
9722 78908 bool rEx3btn()
9723 {
9724 78908 return getInput(btnEx3, true);
9725 }
9726 78908 bool rEx4btn()
9727 {
9728 78908 return getInput(btnEx4, true);
9729 }
9730 bool rAxisUp()
9731 {
9732 return getInput(btnAxisUp, true);
9733 }
9734 bool rAxisDown()
9735 {
9736 return getInput(btnAxisDown, true);
9737 }
9738 bool rAxisLeft()
9739 {
9740 return getInput(btnAxisLeft, true);
9741 }
9742 bool rAxisRight()
9743 {
9744 return getInput(btnAxisRight, true);
9745 }
9746
9747 bool rF11()
9748 {
9749 return getInput(btnF11, true);
9750 }
9751 bool rQ()
9752 {
9753 return getInput(btnQ, true);
9754 }
9755 bool rI()
9756 {
9757 return getInput(btnI, true);
9758 }
9759
9760 9990591 bool DrunkUp()
9761 {
9762 9990591 return getInput(btnUp, false, true);
9763 }
9764 9331462 bool DrunkDown()
9765 {
9766 9331462 return getInput(btnDown, false, true);
9767 }
9768 5913521 bool DrunkLeft()
9769 {
9770 5913521 return getInput(btnLeft, false, true);
9771 }
9772 5138042 bool DrunkRight()
9773 {
9774 5138042 return getInput(btnRight, false, true);
9775 }
9776 4281541 bool DrunkcAbtn()
9777 {
9778 4281541 return getInput(btnA, false, true);
9779 }
9780 4182505 bool DrunkcBbtn()
9781 {
9782 4182505 return getInput(btnB, false, true);
9783 }
9784 3781589 bool DrunkcEx1btn()
9785 {
9786 3781589 return getInput(btnEx1, false, true);
9787 }
9788 3781609 bool DrunkcEx2btn()
9789 {
9790 3781609 return getInput(btnEx2, false, true);
9791 }
9792 bool DrunkcSbtn()
9793 {
9794 return getInput(btnS, false, true);
9795 }
9796 bool DrunkcMbtn()
9797 {
9798 return getInput(btnM, false, true);
9799 }
9800 bool DrunkcLbtn()
9801 {
9802 return getInput(btnL, false, true);
9803 }
9804 bool DrunkcRbtn()
9805 {
9806 return getInput(btnR, false, true);
9807 }
9808 bool DrunkcPbtn()
9809 {
9810 return getInput(btnP, false, true);
9811 }
9812
9813 bool DrunkrUp()
9814 {
9815 return getInput(btnUp, true, true);
9816 }
9817 bool DrunkrDown()
9818 {
9819 return getInput(btnDown, true, true);
9820 }
9821 bool DrunkrLeft()
9822 {
9823 return getInput(btnLeft, true, true);
9824 }
9825 bool DrunkrRight()
9826 {
9827 return getInput(btnRight, true, true);
9828 }
9829 3152476 bool DrunkrAbtn()
9830 {
9831 3152476 return getInput(btnA, true, true);
9832 }
9833 3143791 bool DrunkrBbtn()
9834 {
9835 3143791 return getInput(btnB, true, true);
9836 }
9837 71669 bool DrunkrEx1btn()
9838 {
9839 71669 return getInput(btnEx1, true, true);
9840 }
9841 71662 bool DrunkrEx2btn()
9842 {
9843 71662 return getInput(btnEx2, true, true);
9844 }
9845 bool DrunkrEx3btn()
9846 {
9847 return getInput(btnEx3, true, true);
9848 }
9849 bool DrunkrEx4btn()
9850 {
9851 return getInput(btnEx4, true, true);
9852 }
9853 bool DrunkrSbtn()
9854 {
9855 return getInput(btnS, true, true);
9856 }
9857 bool DrunkrMbtn()
9858 {
9859 return getInput(btnM, true, true);
9860 }
9861 3462285 bool DrunkrLbtn()
9862 {
9863 3462285 return getInput(btnL, true, true);
9864 }
9865 3460467 bool DrunkrRbtn()
9866 {
9867 3460467 return getInput(btnR, true, true);
9868 }
9869 bool DrunkrPbtn()
9870 {
9871 return getInput(btnP, true, true);
9872 }
9873
9874 4964 void eat_buttons()
9875 {
9876 4964 getInput(btnA, true, false, true);
9877 4964 getInput(btnB, true, false, true);
9878 4964 getInput(btnS, true, false, true);
9879 4964 getInput(btnM, true, false, true);
9880 4964 getInput(btnL, true, false, true);
9881 4964 getInput(btnR, true, false, true);
9882 4964 getInput(btnP, true, false, true);
9883 4964 getInput(btnEx1, true, false, true);
9884 4964 getInput(btnEx2, true, false, true);
9885 4964 getInput(btnEx3, true, false, true);
9886 4964 getInput(btnEx4, true, false, true);
9887 4964 }
9888
9889 // Is true for the _first frame_ of a key press.
9890 // But! it is possible that a script manually sets the value of KeyPress,
9891 // in which case it will be restored to the "true" value based on `key_current_frame`
9892 // and `key_previous_frame` on the next frame.
9893 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9894 {
9895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9897 {
9898 case KEY_F7:
9899 case KEY_F8:
9900 case KEY_F9:
9901 return KeyPress[k];
9902
9903 default:
9904
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9905 }
9906 14 }
9907
9908 // Is true for _every frame_ a key is held down.
9909 // But! it is possible that a script manually sets the value of KeyInput,
9910 // in which case it will be restored to the "true" value based on `key_current_frame`
9911 // on the next frame.
9912 bool zc_getkey(int32_t k, bool ignoreDisable)
9913 {
9914 if(ignoreDisable) return KeyInput[k];
9915 switch(k)
9916 {
9917 case KEY_F7:
9918 case KEY_F8:
9919 case KEY_F9:
9920 return KeyInput[k];
9921
9922 default:
9923 return KeyInput[k] && !disabledKeys[k];
9924 }
9925 }
9926
9927 // Reads (and then clears) the current frame key state directly.
9928 // Scripts can also modify `key_current_frame`.
9929 88 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9930 {
9931
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 87 times.
88 if(zc_getrawkey(k, ignoreDisable))
9932 {
9933 1 _key[k]=key[k]=key_current_frame[k]=0;
9934 1 return true;
9935 }
9936 87 _key[k]=key[k]=key_current_frame[k]=0;
9937 87 return false;
9938 88 }
9939
9940 // Reads the current frame key state directly.
9941 // Scripts can also modify `key_current_frame`.
9942 31353397 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9943 {
9944
2/2
✓ Branch 0 taken 26552753 times.
✓ Branch 1 taken 4800644 times.
31353397 if(ignoreDisable) return key_current_frame[k];
9945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800644 times.
4800644 switch(k)
9946 {
9947 case KEY_F7:
9948 case KEY_F8:
9949 case KEY_F9:
9950 return key_current_frame[k];
9951
9952 default:
9953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4800644 times.
4800644 return key_current_frame[k] && !disabledKeys[k];
9954 }
9955 31353397 }
9956
9957 // Only used for a handful of keys, like tilde and Function keys.
9958 // This state is never read within the game.
9959 // It exists so that all keyboard input still functions during replay,
9960 // without inadvertently doing things like toggling throttling if the player
9961 // presses ~
9962 9601291 bool zc_get_system_key(int32_t k)
9963 {
9964 9601291 return key_system[k];
9965 }
9966
9967 // True for the _first_ frame of a key press.
9968 43205544 bool zc_read_system_key(int32_t k)
9969 {
9970 43205544 return key_system_press[k];
9971 }
9972
9973 609678232 bool is_system_key(int32_t k)
9974 {
9975
2/2
✓ Branch 0 taken 566472688 times.
✓ Branch 1 taken 43205544 times.
609678232 switch (k)
9976 {
9977 case KEY_BACKQUOTE:
9978 case KEY_CLOSEBRACE:
9979 case KEY_END:
9980 case KEY_HOME:
9981 case KEY_OPENBRACE:
9982 case KEY_PGDN:
9983 case KEY_PGUP:
9984 case KEY_TAB:
9985 case KEY_TILDE:
9986 43205544 return true;
9987 }
9988 566472688 return is_Fkey(k);
9989 609678232 }
9990
9991 4800616 void update_system_keys()
9992 {
9993
2/2
✓ Branch 0 taken 609678232 times.
✓ Branch 1 taken 4800616 times.
614478848 for (int32_t q = 0; q < 127; ++q)
9994 {
9995
2/2
✓ Branch 0 taken 100812936 times.
✓ Branch 1 taken 508865296 times.
609678232 if (!is_system_key(q))
9996 508865296 continue;
9997
9998 100812936 key_system[q] = key[q];
9999
1/2
✓ Branch 0 taken 100812936 times.
✗ Branch 1 not taken.
100812936 key_system_press[q] = key_system[q] && !key_system_previous[q];
10000 100812936 key_system_previous[q] = key_system[q];
10001 100812936 }
10002 4800616 }
10003
10004 5918082 void update_keys()
10005 {
10006
2/2
✓ Branch 0 taken 751596414 times.
✓ Branch 1 taken 5918082 times.
757514496 for (int32_t q = 0; q < 127; ++q)
10007 {
10008 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10009
1/2
✓ Branch 0 taken 751596414 times.
✗ Branch 1 not taken.
751596414 if (!replay_is_replaying())
10010 key_current_frame[q] = key[q];
10011
10012
2/2
✓ Branch 0 taken 746262464 times.
✓ Branch 1 taken 5333950 times.
751596414 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10013 751596414 KeyInput[q] = key_current_frame[q];
10014 751596414 key_previous_frame[q] = key_current_frame[q];
10015 751596414 }
10016 5918082 }
10017
10018 bool zc_disablekey(int32_t k, bool val)
10019 {
10020 switch(k)
10021 {
10022 case KEY_F7:
10023 case KEY_F8:
10024 case KEY_F9:
10025 return false;
10026
10027 default:
10028 disabledKeys[k] = val;
10029 return true;
10030 }
10031 }
10032
10033 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10034 {
10035 timer=timer;
10036 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10037 }
10038
10039 // these are here so that copy_dialog won't choke when compiling zelda
10040 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10041 {
10042 return D_O_K;
10043 }
10044
10045 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10046 {
10047 return D_O_K;
10048 }
10049
10050 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10051 {
10052 return D_O_K;
10053 }
10054
10055 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10056 {
10057 return D_O_K;
10058 }
10059
10060 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10061 {
10062 return D_O_K;
10063 }
10064
10065 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10066 {
10067 return D_O_K;
10068 }
10069
10070 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10071 {
10072 return D_O_K;
10073 }
10074
10075 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10076 {
10077 return D_O_K;
10078 }
10079
10080 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10081 {
10082 return D_O_K;
10083 }
10084
10085 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10086 {
10087 return D_O_K;
10088 }
10089
10090 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10091 {
10092 return D_O_K;
10093 }
10094
10095 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10096 {
10097 return D_O_K;
10098 }
10099
10100 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10101 {
10102 return D_O_K;
10103 }
10104
10105 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10106 {
10107 return D_O_K;
10108 }
10109
10110 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10111 {
10112 return D_O_K;
10113 }
10114
10115 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10116 {
10117 return D_O_K;
10118 }
10119
10120 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10121 {
10122 return D_O_K;
10123 }
10124
10125 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10126 {
10127 return D_O_K;
10128 }
10129
10130 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10131 {
10132 return D_O_K;
10133 }
10134
10135 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10136 {
10137 return D_O_K;
10138 }
10139
10140 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10141 {
10142 return D_O_K;
10143 }
10144
10145 /*** end of zc_sys.cc ***/
10146
10147